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

Chen Liang liach at openjdk.org
Mon Apr 29 17:23:13 UTC 2024


On Mon, 29 Apr 2024 17:09:24 GMT, ExE Boss <duke at openjdk.org> wrote:

>> 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();
> 	}
> }

@ExE-Boss This patch intentionally does not support the said case. Reason being that an instance method will require a hidden class receiver, yet this receiver cannot be represented as part of a method type from the constant pool; so even if you grab the MH from condy, you still cannot `invokeExact` in bytecode, but have to perform an `asType` conversion first (or just use plain `invoke`)

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

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


More information about the core-libs-dev mailing list