RFR: 8357653: Inner classes of type parameters emitted as raw types in signatures [v8]
Aggelos Biboudis
abimpoudis at openjdk.org
Tue Jul 8 20:01:43 UTC 2025
> There are various occasions that the qualifier of an _inner type_ needs to be normalized.
>
> Briefly:
>
> - This occurs when there is an explicit type application in the signature of the method or a type application operation or when type checking an expression operation (e.g., `G.Getter` in the first example, `M.B<?>` in the second example).
> - The reference to an inner type may not be explicitly qualified (e.g., `B<?>` which is not qualified but its type needs be calculated as seen from `A<String>.B<?>`).
>
> Semi-formally:
>
> - A type reference is simple name `R`:
>
> - `R` is a non-inner class type, nothing to do
> - `R` is an inner class type, we need to find an implicit type qualifier `S<T>.R`, where `S` is the class in which `R` is enclosed
> - `R` is an array type `A[]`, repeat the analysis for the simple type name `A`, and then use the implicit type qualifier to rewrite the array
>
> - A type reference is a qualified name `Q.R`
>
> - find the supertype of `Q`, namely `S<T>`, where `S` is the class in which `R` is enclosed
>
>
>
> // example 1
> static class Usage1<T, G extends Getters<T>> {
> public T test(G.Getter getter) {
> return getter.get();
> }
> }
>
> // example 2
> class A<T> {
> protected class B<V> {}
>
> public static <T, M extends A<T>> void f(Object g) {
> @SuppressWarnings("unchecked")
> M.B<?> mapping = (M.B<?>) g;
> }
> }
>
> // example 3
> class A<T> {
> class B<W> {
> public T rett() { return null; }
> }
> }
>
> class C extends A<String> {
> static class D {
> {
> B<?> b = null;
> String s = b.rett();
> }
> }
> }
Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 10 additional commits since the last revision:
- Merge branch 'master' into JDK-8357653
- Restore missing imports
- Extract common functionality from asOuterSuper/asEnclosingSuper
- Improve comments of asEnclosingSuper/asOuterSuper
- Revert rename of asEnclosingSuper/asOuterSuper
- Add test from 8357472 and simplify both methods getOuterSuper/getOwnerSuper
- Remove unused field in test
- Restore formatting of asOuterSuper
- Address review
- 8357653: Inner classes of type parameters emitted as raw types in signatures
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/25451/files
- new: https://git.openjdk.org/jdk/pull/25451/files/1f93dc7b..95f458f0
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=25451&range=07
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=25451&range=06-07
Stats: 123245 lines in 2481 files changed: 73542 ins; 31287 del; 18416 mod
Patch: https://git.openjdk.org/jdk/pull/25451.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25451/head:pull/25451
PR: https://git.openjdk.org/jdk/pull/25451
More information about the compiler-dev
mailing list