RFR: 8294960: Convert java.base/java.lang.invoke package to use the Classfile API to generate lambdas and method handles [v2]

Adam Sotona asotona at openjdk.org
Fri Dec 15 13:05:40 UTC 2023


On Fri, 15 Dec 2023 12:27:16 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   added missing comment
>
> src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java line 548:
> 
>> 546:     static ClassDesc classDesc(Class<?> cls) {
>> 547:         return cls.isHidden() ? ClassDesc.ofInternalName(cls.getName().replace('.', '/'))
>> 548:                               : ClassDesc.ofDescriptor(cls.descriptorString());
> 
> This still isn’t correct, as [`Class::getName()`] includes the trailing `/<suffix>` for a hidden class.
> Suggestion:
> 
>         if (cls.isHidden()) {
>             var name = cls.getName();
>             return ClassDesc.of(name.substring(0, name.indexOf('/'));
>         }
>         return ClassDesc.ofDescriptor(cls.descriptorString());
> 
> 
> [`Class::getName()`]: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Class.html#getName()

This is fix of `runtime/cds/appcds/dynamicArchive/LambdaProxyCallerIsHidden.java` test.
It is based on the original code way of getting the class name.
Cutting of the class name behind the first slash will remove important suffix.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17108#discussion_r1427953577


More information about the core-libs-dev mailing list