Skip to content

Commit bda4427

Browse files
committed
Match RI behaviour for MethodHandles.unrelfect with OpenJDK MHs
This patch addresses eclipse-openj9/openj9#14985. For MethodHandles to private interface methods, the RI erroneously initializes the MethodHandle to have an InvokeInterface reference kind, leading to an invoke-time AbstractMethodError throw. As per the spec, OpenJ9 initializes MethodHandles to private interface methods to have an InvokeSpecial reference kind which does not throw the error. This distinction causes a test failure for a test reported in eclipse-openj9/openj9#14985. Though not-spec compliant, the test expects an AbstractMethodError to be thrown to conform to the RI behaviour. For OpenJ9 MHs, MethodHandles.unreflect identifies private interface methods and installs an AbstractMethodError-thrower MH. This patch sets up a similar mechanism for OpenJDK MHs by calling a MethodHandleResolver method that installs the AbstractMethodError-thrower MH. Issues: eclipse-openj9/openj9#14985 Signed-off-by: Nathan Henderson <[email protected]>
1 parent 5a3af11 commit bda4427

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

jdk/src/share/classes/java/lang/invoke/MethodHandles.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* or visit www.oracle.com if you need additional information or have any
2323
* questions.
2424
*/
25+
/*
26+
* ===========================================================================
27+
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
28+
* ===========================================================================
29+
*/
2530

2631
package java.lang.invoke;
2732

@@ -1183,6 +1188,10 @@ public MethodHandle unreflect(Method m) throws IllegalAccessException {
11831188
MethodHandle mh = unreflectForMH(m);
11841189
if (mh != null) return mh;
11851190
}
1191+
1192+
MethodHandle mh = MethodHandleResolver.maybeCreateAbstractMethodErrorThrower(m);
1193+
if (mh != null) return mh;
1194+
11861195
MemberName method = new MemberName(m);
11871196
byte refKind = method.getReferenceKind();
11881197
if (refKind == REF_invokeSpecial)

0 commit comments

Comments
 (0)