--- jsr166/src/test/tck/JSR166TestCase.java 2021/01/27 02:13:22 1.273 +++ jsr166/src/test/tck/JSR166TestCase.java 2022/03/22 16:26:19 1.274 @@ -195,8 +195,9 @@ import junit.framework.TestSuite; * */ public class JSR166TestCase extends TestCase { + // No longer run with custom securityManagers private static final boolean useSecurityManager = - Boolean.getBoolean("jsr166.useSecurityManager"); + Boolean.getBoolean("jsr166.useSecurityManager"); protected static final boolean expensiveTests = Boolean.getBoolean("jsr166.expensiveTests"); @@ -407,6 +408,7 @@ public class JSR166TestCase extends Test * Runs all unit tests in the given test suite. * Actual behavior influenced by jsr166.* system properties. */ + @SuppressWarnings("removal") static void main(Test suite, String[] args) { if (useSecurityManager) { System.err.println("Setting a permissive security manager"); @@ -452,14 +454,18 @@ public class JSR166TestCase extends Test public static final String JAVA_SPECIFICATION_VERSION; static { try { - JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged( + @SuppressWarnings("removal") double jcv = + java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Double run() { return Double.valueOf(System.getProperty("java.class.version"));}}); - JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged( + JAVA_CLASS_VERSION = jcv; + @SuppressWarnings("removal") String jsv = + java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public String run() { return System.getProperty("java.specification.version");}}); + JAVA_SPECIFICATION_VERSION = jsv; } catch (Throwable t) { throw new Error(t); } @@ -596,6 +602,12 @@ public class JSR166TestCase extends Test addNamedTestClasses(suite, java9TestClassNames); } + if (atLeastJava17()) { + String[] java17TestClassNames = { + "ForkJoinPool19Test", + }; + addNamedTestClasses(suite, java17TestClassNames); + } return suite; } @@ -1054,7 +1066,7 @@ public class JSR166TestCase extends Test void joinPool(ExecutorService pool) { try { pool.shutdown(); - if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) { + if (!pool.awaitTermination(20 * LONG_DELAY_MS, MILLISECONDS)) { try { threadFail("ExecutorService " + pool + " did not terminate in a timely manner"); @@ -1138,6 +1150,7 @@ public class JSR166TestCase extends Test * A debugging tool to print stack traces of most threads, as jstack does. * Uninteresting threads are filtered out. */ + @SuppressWarnings("removal") static void dumpTestThreads() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -1346,9 +1359,7 @@ public class JSR166TestCase extends Test assertTrue(c.remove(i)); } static void mustNotRemove(Collection c, int i) { - Item[] items = defaultItems; - Item x = (i >= 0 && i < items.length) ? items[i] : new Item(i); - assertFalse(c.remove(x)); + assertFalse(c.remove(itemFor(i))); } static void mustNotRemove(Collection c, Item i) { assertFalse(c.remove(i)); @@ -1373,6 +1384,7 @@ public class JSR166TestCase extends Test * security manager. We require that any security manager permit * getPolicy/setPolicy. */ + @SuppressWarnings("removal") public void runWithPermissions(Runnable r, Permission... permissions) { SecurityManager sm = System.getSecurityManager(); if (sm == null) { @@ -1388,8 +1400,10 @@ public class JSR166TestCase extends Test * Runnable. We require that any security manager permit * getPolicy/setPolicy. */ + @SuppressWarnings("removal") public void runWithSecurityManagerWithPermissions(Runnable r, Permission... permissions) { + if (!useSecurityManager) return; SecurityManager sm = System.getSecurityManager(); if (sm == null) { Policy savedPolicy = Policy.getPolicy(); @@ -1426,6 +1440,7 @@ public class JSR166TestCase extends Test * A security policy where new permissions can be dynamically added * or all cleared. */ + @SuppressWarnings("removal") public static class AdjustablePolicy extends java.security.Policy { Permissions perms = new Permissions(); AdjustablePolicy(Permission... permissions) { @@ -1455,6 +1470,7 @@ public class JSR166TestCase extends Test /** * Returns a policy containing all the permissions we ever need. */ + @SuppressWarnings("removal") public static Policy permissivePolicy() { return new AdjustablePolicy // Permissions j.u.c. needs directly