Skip to content

Commit

Permalink
Merge pull request #18396 from ThanHenderson/14989-8
Browse files Browse the repository at this point in the history
Adapt getCallerClass MH tests for ojdk8 MHs
  • Loading branch information
babsingh authored Nov 8, 2023
2 parents 406c9da + e2b736f commit 04f76db
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
*/
public class ReflectionMHTests {

private static boolean isSecurityFrameOrInjectedInvoker(Class<?> cls) {
return ("java.lang.invoke.SecurityFrame" == cls.getName()
|| cls.getName().startsWith("java.lang.invoke.MethodHandleImpl$BindCaller$T/"));
}

/**
* Call getCallerClass() with a helper method via reflection from the bootstrap/extension
* classloader
Expand Down Expand Up @@ -108,7 +113,7 @@ public static boolean test_getCallerClass_Helper_MethodHandle_fromBootExtWithAnn
methodHandle = lookup.findStatic(GetCallerClassTests.class, "test_getCallerClass_MethodHandle", methodType);
cls = (Class<?>) methodHandle.invoke();

if ("java.lang.invoke.SecurityFrame" == cls.getName()) {
if (isSecurityFrameOrInjectedInvoker(cls)) {
System.out.println(TESTCASE_NAME + ": PASSED: return " + cls.getName());
return true;
} else {
Expand Down Expand Up @@ -174,7 +179,7 @@ public static boolean test_getCallerClass_MethodHandle_ArgumentHelper() {
MethodHandle mhResult = MethodHandles.foldArguments(mhTarget, mhCombiner);
cls = (Class<?>) mhResult.invoke();

if ("java.lang.invoke.SecurityFrame" == cls.getName()) {
if (isSecurityFrameOrInjectedInvoker(cls)) {
System.out.println(TESTCASE_NAME + ": PASSED: return " + cls.getName());
return true;
} else {
Expand Down

0 comments on commit 04f76db

Please sign in to comment.