RFR: 8330467: NoClassDefFoundError when lambda is in a hidden class [v2]
Paul Sandoz
psandoz at openjdk.org
Wed Apr 17 15:42:01 UTC 2024
On Wed, 17 Apr 2024 12:51:55 GMT, Adam Sotona <asotona 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
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>
> applied suggested changes
test/jdk/java/lang/invoke/defineHiddenClass/src/Lambda.java line 28:
> 26: public class Lambda implements HiddenTest {
> 27: public void test() {
> 28: Function<Object, String> f = o -> o.toString();
Recommend you retain the existing method reference e.g.:
Function<Object, String> fmref = Object::toString;
Function<Object, String> flexp = o -> o.toString();
String s = fmref.apply(this) + flexp.apply(this);
...
Or split them out into two tests (easier to debug if case fails).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18810#discussion_r1569060714
More information about the core-libs-dev
mailing list