Skip to content

Commit

Permalink
Merge pull request #20159 from r30shah/disableDMHPR
Browse files Browse the repository at this point in the history
Disable use of method handle for core reflection in JDK21
  • Loading branch information
keithc-ca authored Sep 18, 2024
2 parents 8393fab + 3fc532d commit 17a3fe8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions jcl/src/java.base/share/classes/java/lang/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ private static void ensureProperties(boolean isInitialization) {
initializedProperties.put("native.encoding", platformEncoding); //$NON-NLS-1$
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */

/*[IF JAVA_SPEC_VERSION == 21]*/
initializedProperties.putIfAbsent("jdk.reflect.useDirectMethodHandle", "false");
/*[ENDIF] JAVA_SPEC_VERSION == 21 */

/*[IF (JAVA_SPEC_VERSION >= 21) & (PLATFORM-mz31 | PLATFORM-mz64)]*/
initializedProperties.put("com.ibm.autocvt", zOSAutoConvert); //$NON-NLS-1$
/*[ENDIF] (JAVA_SPEC_VERSION >= 21) & (PLATFORM-mz31 | PLATFORM-mz64) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public static boolean test_getCallerClass_Helper_Reflection_fromBootExtWithAnnot
cls = (Class<?>) method.invoke(null, new Object[0]);

boolean isClassNameExpected;
if (VersionCheck.major() >= 18) {
if ((VersionCheck.major() >= 18)
&& (Boolean.getBoolean("jdk.reflect.useDirectMethodHandle") || (VersionCheck.major() != 21))
) {
isClassNameExpected = isSecurityFrameOrInjectedInvoker(cls);
} else {
isClassNameExpected = (cls == ReflectionMHTests.class);
Expand Down

0 comments on commit 17a3fe8

Please sign in to comment.