Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conform to spec for interface resolution for OJDK MHs #18476

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions runtime/jcl/common/java_lang_invoke_MethodHandleNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,17 @@ Java_java_lang_invoke_MethodHandleNatives_resolve(
new_flags |= MN_IS_METHOD;
if (MH_REF_INVOKEINTERFACE == ref_kind) {
Assert_JCL_true(J9_ARE_NO_BITS_SET(methodModifiers, J9AccStatic));
#if JAVA_SPEC_VERSION < 11
/* Ensure findVirtual throws an IllegalAccessException (by wrapping this IncompatibleClassChangeError)
* when trying to access a private interface method for Java 10- with OpenJDK MHs.
*/
if (J9_ARE_NO_BITS_SET(lookupOptions, J9_LOOK_STATIC)
&& J9_ARE_ALL_BITS_SET(methodModifiers, J9AccPrivate)
) {
vmFuncs->setCurrentExceptionUTF(currentThread, J9VMCONSTANTPOOL_JAVALANGINCOMPATIBLECLASSCHANGEERROR, NULL);
goto done;
}
#endif /* JAVA_SPEC_VERSION < 11 */
if (J9_ARE_ALL_BITS_SET(methodID->vTableIndex, J9_JNI_MID_INTERFACE)) {
new_flags |= MH_REF_INVOKEINTERFACE << MN_REFERENCE_KIND_SHIFT;
} else if (!J9ROMMETHOD_HAS_VTABLE(romMethod)) {
Expand Down