On Fri, 15 Dec 2023 13:02:57 GMT, Adam Sotona <[email protected]> wrote:
>> 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.
Notice that hidden classes can be created by providing a javac-produced class
file, and is frequently used to redefine the same class multiple times
(distinguished by their random suffix) in tests. Thus hidden classes may
totally use bootstrap methods like lambda or enhanced switch and their
secondary hidden classes must be distinguished from each other.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17108#discussion_r1428836408