RFR: 8357653: Inner classes of type parameters emitted as raw types in signatures [v18]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Jul 14 21:05:43 UTC 2025
On Mon, 14 Jul 2025 12:34:30 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:
>> 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 incrementally with one additional commit since the last revision:
>
> Reduce comments
Looks very good, I left two optional minor doc changes
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 2248:
> 2246: * class I {
> 2247: * void test() {
> 2248: * String f2 = f; // Sup<String>
Suggestion:
* String f2 = f; // Sup<String>::f
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 2278:
> 2276: * class C extends A<String> {
> 2277: * static class D {
> 2278: * B b; // qualifier is A<String>.B
Suggestion:
* B b; // A<String>.B
-------------
Marked as reviewed by mcimadamore (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/25451#pullrequestreview-3017839826
PR Review Comment: https://git.openjdk.org/jdk/pull/25451#discussion_r2205825684
PR Review Comment: https://git.openjdk.org/jdk/pull/25451#discussion_r2205826160
More information about the compiler-dev
mailing list