RFR: 8268192: LambdaMetafactory with invokespecial causes VerificationError [v2]
Dan Smith
dlsmith at openjdk.java.net
Tue Jun 8 15:30:35 UTC 2021
On Tue, 8 Jun 2021 02:23:09 GMT, liach <github.com+7806504+liach at openjdk.org> wrote:
>> Dan Smith has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Clean up validation of implKind REF_invokeSpecial
>
> src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java line 191:
>
>> 189: useImplMethodHandle = (Modifier.isProtected(implInfo.getModifiers()) &&
>> 190: !VerifyAccess.isSamePackage(implClass, implInfo.getDeclaringClass())) ||
>> 191: implKind == H_INVOKESPECIAL;
>
> Won't this make regular private instance method calls use condy as well, as they are invokespecial?
See this code from the `AbstractValidatingLambdaMetafactory` constructor:
case REF_invokeSpecial:
// JDK-8172817: should use referenced class here, but we don't know what it was
this.implClass = implInfo.getDeclaringClass();
this.implIsInstanceMethod = true;
// Classes compiled prior to dynamic nestmate support invokes a private instance
// method with REF_invokeSpecial.
//
// invokespecial should only be used to invoke private nestmate constructors.
// The lambda proxy class will be defined as a nestmate of targetClass.
// If the method to be invoked is an instance method of targetClass, then
// convert to use invokevirtual or invokeinterface.
if (targetClass == implClass && !implInfo.getName().equals("<init>")) {
this.implKind = implClass.isInterface() ? REF_invokeInterface : REF_invokeVirtual;
} else {
this.implKind = REF_invokeSpecial;
}
break;
We turn all same-class invocations into `invokevirtual`. (And all `<init>` invocations have kind `newInvokeSpecial`, mentioning them here is actually useless.)
-------------
PR: https://git.openjdk.java.net/jdk/pull/4403
More information about the core-libs-dev
mailing list