RFR: 8330467: NoClassDefFoundError when lambda is in a hidden class [v4]

ExE Boss duke at openjdk.org
Mon Apr 29 17:12:16 UTC 2024


On Thu, 18 Apr 2024 05:54:17 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:
> 
>   Update src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
>   
>   Co-authored-by: Mandy Chung <mandy.chung at oracle.com>

This doesn’t fix the case where the lambda is created from an instance method, e.g.:


import java.util.function.Supplier;

public class HiddenLambda implements HiddenTest {
	public String test() {
		Supplier<String> s = this::toString;
		return s.get();
	}

	public String toString() {
		return getClass().getName();
	}
}

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

PR Comment: https://git.openjdk.org/jdk/pull/18810#issuecomment-2083240740


More information about the core-libs-dev mailing list