Skip to content

Commit b4ecea9

Browse files
authored
Merge pull request #18372 from ThanHenderson/14989-11
Adapt getCallerClass MH tests for ojdk11 MHs
2 parents edd7fc3 + e41e8f3 commit b4ecea9

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

test/functional/cmdline_options_testresources/src/com/ibm/j9/getcallerclass/TestGroup.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public static boolean fromBootClassLoader() {
7474

7575
subTestResult &= GetCallerClassTests.test_getCallerClass_fromBootExtWithAnnotation();
7676
subTestResult &= GetCallerClassTests.test_ensureCalledFromBootstrapClass_fromBootWithAnnotation();
77-
subTestResult &= RefectionMHTests.test_getCallerClass_Helper_Reflection_fromBootExtWithAnnotation();
78-
subTestResult &= RefectionMHTests.test_getCallerClass_Direct_Reflection_fromBootExtClassLoader();
79-
subTestResult &= RefectionMHTests.test_getCallerClass_Helper_MethodHandle_fromBootExtWithAnnotation();
80-
subTestResult &= RefectionMHTests.test_getCallerClass_Direct_MethodHandle_fromBootExtClassLoader();
81-
subTestResult &= RefectionMHTests.test_getCallerClass_MethodHandle_ArgumentHelper();
77+
subTestResult &= ReflectionMHTests.test_getCallerClass_Helper_Reflection_fromBootExtWithAnnotation();
78+
subTestResult &= ReflectionMHTests.test_getCallerClass_Direct_Reflection_fromBootExtClassLoader();
79+
subTestResult &= ReflectionMHTests.test_getCallerClass_Helper_MethodHandle_fromBootExtWithAnnotation();
80+
subTestResult &= ReflectionMHTests.test_getCallerClass_Direct_MethodHandle_fromBootExtClassLoader();
81+
subTestResult &= ReflectionMHTests.test_getCallerClass_MethodHandle_ArgumentHelper();
8282

8383
subTestResult &= GetCallerClassTests.test_getCallerClass_fromBootExtWithoutAnnotation();
8484
subTestResult &= GetCallerClassTests.test_ensureCalledFromBootstrapClass_fromBootExtWithoutAnnotation();
@@ -91,11 +91,11 @@ public static boolean fromExtClassLoader() {
9191

9292
subTestResult &= GetCallerClassTests.test_getCallerClass_fromBootExtWithAnnotation();
9393
subTestResult &= GetCallerClassTests.test_ensureCalledFromBootstrapClass_fromExtWithAnnotation();
94-
subTestResult &= RefectionMHTests.test_getCallerClass_Helper_Reflection_fromBootExtWithAnnotation();
95-
subTestResult &= RefectionMHTests.test_getCallerClass_Direct_Reflection_fromBootExtClassLoader();
96-
subTestResult &= RefectionMHTests.test_getCallerClass_Helper_MethodHandle_fromBootExtWithAnnotation();
97-
subTestResult &= RefectionMHTests.test_getCallerClass_Direct_MethodHandle_fromBootExtClassLoader();
98-
subTestResult &= RefectionMHTests.test_getCallerClass_MethodHandle_ArgumentHelper();
94+
subTestResult &= ReflectionMHTests.test_getCallerClass_Helper_Reflection_fromBootExtWithAnnotation();
95+
subTestResult &= ReflectionMHTests.test_getCallerClass_Direct_Reflection_fromBootExtClassLoader();
96+
subTestResult &= ReflectionMHTests.test_getCallerClass_Helper_MethodHandle_fromBootExtWithAnnotation();
97+
subTestResult &= ReflectionMHTests.test_getCallerClass_Direct_MethodHandle_fromBootExtClassLoader();
98+
subTestResult &= ReflectionMHTests.test_getCallerClass_MethodHandle_ArgumentHelper();
9999

100100
subTestResult &= GetCallerClassTests.test_getCallerClass_fromBootExtWithoutAnnotation();
101101
subTestResult &= GetCallerClassTests.test_ensureCalledFromBootstrapClass_fromBootExtWithoutAnnotation();

test/functional/cmdline_options_testresources/src_80/com/ibm/j9/getcallerclass/RefectionMHTests.java renamed to test/functional/cmdline_options_testresources/src_80/com/ibm/j9/getcallerclass/ReflectionMHTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* Test cases intended for reflection and MethodHandle
3333
*/
34-
public class RefectionMHTests {
34+
public class ReflectionMHTests {
3535

3636
/**
3737
* Call getCallerClass() with a helper method via reflection from the bootstrap/extension
@@ -46,7 +46,7 @@ public static boolean test_getCallerClass_Helper_Reflection_fromBootExtWithAnnot
4646
method = GetCallerClassTests.class.getDeclaredMethod("test_getCallerClass_MethodHandle");
4747
cls = (Class<?>) method.invoke(null, new Object[0]);
4848

49-
if (cls == RefectionMHTests.class) {
49+
if (cls == ReflectionMHTests.class) {
5050
System.out.println(TESTCASE_NAME + ": PASSED: return " + cls.getName());
5151
return true;
5252
} else {

test/functional/cmdline_options_testresources/src_90/com/ibm/j9/getcallerclass/RefectionMHTests.java renamed to test/functional/cmdline_options_testresources/src_90/com/ibm/j9/getcallerclass/ReflectionMHTests.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,20 @@
3232
/**
3333
* Test cases intended for reflection and MethodHandle
3434
*/
35-
public class RefectionMHTests {
35+
public class ReflectionMHTests {
3636

3737
private static boolean isSecurityFrameOrInjectedInvoker(Class<?> cls) {
38-
return ("java.lang.invoke.SecurityFrame" == cls.getName()
39-
|| cls.getName().startsWith(RefectionMHTests.class.getName() + "$$InjectedInvoker/"));
38+
boolean rc = "java.lang.invoke.SecurityFrame" == cls.getName();
39+
if (!rc) {
40+
String injectedInvoker;
41+
if (VersionCheck.major() < 15) {
42+
injectedInvoker = ReflectionMHTests.class.getPackageName() + ".InjectedInvoker/";
43+
} else {
44+
injectedInvoker = ReflectionMHTests.class.getName() + "$$InjectedInvoker/";
45+
}
46+
rc = cls.getName().startsWith(injectedInvoker);
47+
}
48+
return rc;
4049
}
4150

4251
/**
@@ -56,7 +65,7 @@ public static boolean test_getCallerClass_Helper_Reflection_fromBootExtWithAnnot
5665
if (VersionCheck.major() >= 18) {
5766
isClassNameExpected = isSecurityFrameOrInjectedInvoker(cls);
5867
} else {
59-
isClassNameExpected = (cls == RefectionMHTests.class);
68+
isClassNameExpected = (cls == ReflectionMHTests.class);
6069
}
6170

6271
if (isClassNameExpected) {

0 commit comments

Comments
 (0)