Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Provide generic types for compiler-added constructor parameters

Open
#1,773 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend

Research direction

Read issue #1772 and trace how getParameterTypes() and JavaParameter.getType() derive types for compiler-added constructor parameters. The issue identifies no source files or tests, so first locate the constructor parameter import logic and its tests. Done means mandated enclosing-instance parameters of inner classes of generic classes retain the enclosing class’s type variables, while raw parameter types remain unchanged.

Written by the indexing model from the issue text.

Description

Summary

Follow-up to #1772. Once getParameterTypes() includes the parameters the compiler adds to constructors of inner classes and enums, those parameters only have the raw type from the method descriptor, because the Signature attribute does not mention them. For the enclosing instance of an inner class of a generic class this loses information that is available elsewhere in the class file.

Example

class Outer<T> {
    class Inner {
        Inner(List<T> list) {}
    }
}

The constructor descriptor is (Outer, List) and the Signature attribute is (List<T>). After #1772, getParameterTypes() reports [Outer, List<T>]. The enclosing instance is really of type Outer<T>, where T is the type variable declared by Outer and visible to Inner. Reflection has the same limitation: Constructor.getParameters()[0].getParameterizedType() is the raw Outer.

Proposal

  • For the mandated enclosing instance parameter, report the enclosing class parameterized with its own type variables (Outer<T>), i.e. the type that Outer.this has inside Inner. The enclosing class and its type parameters are known to the importer, so this needs no new information from the class file.
  • For captured local variables there is nothing to recover: the descriptor only has the erased type (a captured List<String> becomes List), and the Signature attribute does not list these parameters. They stay raw.
  • Enum name and ordinal (String, int) have no generic type anyway.

Scope

Only getParameterTypes() and JavaParameter.getType() of the affected parameters change, and only for inner classes of generic classes. getRawParameterTypes() is unchanged. Ideally this ships in the same release as #1772, so that users see the final shape of getParameterTypes() once.

Dominant language
Java
Stars
3.9k
Forks
350
Avg merge
1d 21h
Merged PRs (30d)
16

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TNG/ArchUnit

All issues in TNG/ArchUnit

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.