diff --git a/tests/src/test/java/org/mozilla/javascript/tests/SecurityControllerTest.java b/tests/src/test/java/org/mozilla/javascript/tests/SecurityControllerTest.java index 1ffbcc6f85..defc10c305 100644 --- a/tests/src/test/java/org/mozilla/javascript/tests/SecurityControllerTest.java +++ b/tests/src/test/java/org/mozilla/javascript/tests/SecurityControllerTest.java @@ -13,6 +13,9 @@ import java.security.ProtectionDomain; import java.security.URIParameter; import java.util.Enumeration; + +import org.hamcrest.CoreMatchers; +import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; import org.mozilla.javascript.ClassShutter; @@ -36,6 +39,7 @@ static void setupSecurityManager() {} /** Setup the security */ @BeforeClass public static void setup() throws Exception { + Assume.assumeThat("Skipping test for Java 21", Utils.isJavaVersionAtLeast(21), CoreMatchers.is(false)); URL url = SecurityControllerTest.class.getResource("grant-all-java.policy"); if (url != null) { System.setProperty("java.security.policy", url.toString()); @@ -69,6 +73,9 @@ private static ProtectionDomain createProtectionDomain(Policy policy, String csS @Test public void barAccess() { + // Security managers are out in Java 21, so skip. + Assume.assumeThat("Skipping test for Java 21", Utils.isJavaVersionAtLeast(21), CoreMatchers.is(false)); + // f.create produces "SomeClass extends ArrayList implements // SomeInterface" // we may access array methods, like 'size' defined by ArrayList, diff --git a/tests/src/test/java/org/mozilla/javascript/tests/Utils.java b/tests/src/test/java/org/mozilla/javascript/tests/Utils.java index 76dab93284..ac7d7d0d94 100644 --- a/tests/src/test/java/org/mozilla/javascript/tests/Utils.java +++ b/tests/src/test/java/org/mozilla/javascript/tests/Utils.java @@ -77,4 +77,10 @@ public static int[] getTestOptLevels() { } return DEFAULT_OPT_LEVELS; } + + public static boolean isJavaVersionAtLeast(int desiredVersion) { + String[] v = System.getProperty("java.version").split("\\."); + int version = Integer.parseInt(v[0]); + return version >= desiredVersion; + } }