RFR: 8357653: Inner classes of type parameters emitted as raw types in signatures [v10]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jul 9 21:14:44 UTC 2025


On Wed, 9 Jul 2025 11:41:22 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 2260:
>> 
>>> 2258:      */
>>> 2259:     public Type asEnclosingSuper(Type t, Symbol sym) {
>>> 2260:         return asOuter(t, sym, type -> getOwnerEnclosingClassType(type));
>> 
>> You could also use a method reference here.
>> 
>> Also... I guess here we have to decide whether it's better to use a method reference, and leave a method like `getOwnerEnclosingClassType` permanently there, or, perhaps, just accept the fact that the logic represented by `getOwnerEnclosingClassType` is a bit weird, and has only really one use, and it belongs to a lambda expression, so as to achieve full encapsulation.
>
> Also, the one is on `Type::getEnclosingType` and the other would be on `Types::getOwnerEnclosingClassType`.
> 
> I this this is too special to make it part of the hierarchy of `Type` and specially the `class DeclaredType`.
> I think I would slightly prefer to keep it as a lambda ultimately to promote the custom logic here. I would strongly prefer to inline it even in the lambda, but there we lose the nice name.

I agree that as a method it would look confusing either in `Type` or in `Symbol`

>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 2280:
>> 
>>> 2278:      * @param nextType a unary operator that emits the next type to be examined
>>> 2279:      */
>>> 2280:     public Type asOuter(Type t, Symbol sym, UnaryOperator<Type> nextType) {
>> 
>> IMHO, this method should be called `asSuperXYZ` -- because that's what it does. It basically calls `asSuper` repeatedly (on the types returned by the unary operator) until a match is found.
>
> Ah, `asSuperClosure` would be nice. But there is another one called `superClosure`. What about `asSuperUpward`?

I agree `asSuperClosure` is (very) nice. IMHO, use that, and rename the other to `supertypeClosure` as (1) that's what it is and (2) it only has one usage that I can see, so renaming is not a big deal and (3) it's a private method in Types, so no risk of it being exposed and accessed elsewhere.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25451#discussion_r2195986619
PR Review Comment: https://git.openjdk.org/jdk/pull/25451#discussion_r2195983582


More information about the compiler-dev mailing list