On Wed, 17 Apr 2024 12:51:55 GMT, Adam Sotona <asot...@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

Reply via email to