RFR: 8330467: NoClassDefFoundError when lambda is in a hidden class
Adam Sotona
asotona at openjdk.org
Wed Apr 17 12:47:00 UTC 2024
On Wed, 17 Apr 2024 09:14:31 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Current implementation of `LambdaMetafactory` does not allow to use lambdas in hidden classes. Invocation throws `NoClassDefFoundError` instead.
>>
>> This patch includes lambda implementation in a hidden class under the special handling of `useImplMethodHandle`.
>> The patch also fixes `j/l/i/defineHiddenClass/BasicTest::testLambda` to correctly cover this test case.
>>
>> Please review.
>>
>> Thanks,
>> Adam
>
> src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java line 186:
>
>> 184: !VerifyAccess.isSamePackage(targetClass, implInfo.getDeclaringClass())) ||
>> 185: implKind == H_INVOKESPECIAL ||
>> 186: implInfo.getDeclaringClass().isHidden();
>
> Might need to check the difference between `implInfo.getDeclaringClass()` and `implClass`
Yes, we should support only invoke static refs for hidden classes and `implClass == implInfo.getDeclaringClass()` in that case.
Thanks!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18810#discussion_r1568782761
More information about the core-libs-dev
mailing list