Provide generic types for compiler-added constructor parameters
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
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 thatOuter.thishas insideInner. 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>becomesList), and theSignatureattribute 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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TNG/ArchUnit
-
Constructor parameters added by the compiler (inner classes, enums) make `getParameters()` / `getParameterTypes()` inconsistent and misplace parameter annotationsPossibly taken @SamuelAdigos claimed this 1 day ago. Open
Difficulty 5/5 Over a week Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
breaking change
Difficulty 5/5 Over a week Newbie friendliness 18/100
TNG/ArchUnit#1756 · 1 comment ·
Maintainers usually reply within 1 day
-
breaking change
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 1 day
-
breaking change
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Maintainers usually reply within 1 day
-
breaking change
Difficulty 3/5 Half a day Newbie friendliness 62/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
oracle/graalvm-reachability-metadata#11472 ·
Maintainers usually reply within 1 day
-
OkHttp versions 5.4.0+ no longer include baseline-prof.txtPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 1/5 Under an hour Newbie friendliness 83/100
lysine-dev/okhttp#9828 ·
Maintainers usually reply within 1 day
-
status: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
spring-projects/spring-ai#7269 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 89/100
objectionary/hone-maven-plugin#1353 ·
Maintainers usually reply within 9 days
-
ClassNotFoundException: io.netty.channel.kqueue.KQueueEventLoop stack trace printed during native build on main (Netty 4.2 removed the class)Possibly taken @gastaldi claimed this today. Openarea/netty kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
quarkusio/quarkus#57939 · 1 comment ·
Maintainers usually reply within 1 day