RFR: 8294960: Convert java.base/java.lang.invoke package to use the Classfile API to generate lambdas and method handles [v2]

ExE Boss duke at openjdk.org
Sat Dec 16 17:32:40 UTC 2023


On Fri, 15 Dec 2023 12:26:50 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> java.base java.lang.invoke package heavily uses ASM to generate lambdas and method handles.
>> 
>> This patch converts ASM calls to Classfile API.
>> 
>> This PR is continuation of https://github.com/openjdk/jdk/pull/12945
>> 
>> Any comments and suggestions are welcome.
>> 
>> Please review.
>> 
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
> 
>   added missing comment

src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java line 187:

> 185:         // generating bridges in the target class)
> 186:         useImplMethodHandle = (Modifier.isProtected(implInfo.getModifiers()) &&
> 187:                                !VerifyAccess.isSamePackage(targetClass, implInfo.getDeclaringClass())) ||

If the `implClass` is hidden, then it’s not possible to generate bytecode which correctly refers to `implMethod`, so the only way is to use the method handle in that case:
Suggestion:

        useImplMethodHandle = (Modifier.isProtected(implInfo.getModifiers()) &&
                               !VerifyAccess.isSamePackage(targetClass, implInfo.getDeclaringClass())) ||
                               implClass.isHidden() ||

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17108#discussion_r1428867973


More information about the core-libs-dev mailing list