--- jsr166/src/test/tck/ExecutorsTest.java 2019/12/16 22:55:54 1.51 +++ jsr166/src/test/tck/ExecutorsTest.java 2022/03/22 21:29:23 1.56 @@ -206,7 +206,7 @@ public class ExecutorsTest extends JSR16 await(proceed); }}; long startTime = System.nanoTime(); - Future f = p.schedule(Executors.callable(task, Boolean.TRUE), + Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); @@ -230,7 +230,7 @@ public class ExecutorsTest extends JSR16 await(proceed); }}; long startTime = System.nanoTime(); - Future f = p.schedule(Executors.callable(task, Boolean.TRUE), + Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); @@ -256,7 +256,7 @@ public class ExecutorsTest extends JSR16 await(proceed); }}; long startTime = System.nanoTime(); - Future f = p.schedule(Executors.callable(task, Boolean.TRUE), + Future f = p.schedule(Executors.callable(task, Boolean.TRUE), timeoutMillis(), MILLISECONDS); assertFalse(f.isDone()); proceed.countDown(); @@ -279,21 +279,24 @@ public class ExecutorsTest extends JSR16 Executors.newScheduledThreadPool(2), }; - final Runnable sleeper = new CheckedInterruptedRunnable() { + final CountDownLatch done = new CountDownLatch(1); + + final Runnable sleeper = new CheckedRunnable() { public void realRun() throws InterruptedException { - delay(LONG_DELAY_MS); + done.await(LONG_DELAY_MS, MILLISECONDS); }}; List threads = new ArrayList<>(); for (final ExecutorService executor : executors) { threads.add(newStartedThread(new CheckedRunnable() { public void realRun() { - Future future = executor.submit(sleeper); + Future future = executor.submit(sleeper); assertFutureTimesOut(future); }})); } for (Thread thread : threads) awaitTermination(thread); + done.countDown(); for (ExecutorService executor : executors) joinPool(executor); } @@ -302,6 +305,7 @@ public class ExecutorsTest extends JSR16 * ThreadPoolExecutor using defaultThreadFactory has * specified group, priority, daemon status, and name */ + @SuppressWarnings("removal") public void testDefaultThreadFactory() throws Exception { final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); final CountDownLatch done = new CountDownLatch(1); @@ -332,6 +336,7 @@ public class ExecutorsTest extends JSR16 * specified group, priority, daemon status, name, * access control context and context class loader */ + @SuppressWarnings("removal") public void testPrivilegedThreadFactory() throws Exception { final CountDownLatch done = new CountDownLatch(1); Runnable r = new CheckedRunnable() { @@ -365,6 +370,7 @@ public class ExecutorsTest extends JSR16 new RuntimePermission("modifyThread")); } + @SuppressWarnings("removal") boolean haveCCLPermissions() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -378,6 +384,7 @@ public class ExecutorsTest extends JSR16 return true; } + @SuppressWarnings("removal") void checkCCL() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -397,6 +404,7 @@ public class ExecutorsTest extends JSR16 * Without class loader permissions, creating * privilegedCallableUsingCurrentClassLoader throws ACE */ + @SuppressWarnings("removal") public void testCreatePrivilegedCallableUsingCCLWithNoPrivs() { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { @@ -415,6 +423,7 @@ public class ExecutorsTest extends JSR16 * With class loader permissions, calling * privilegedCallableUsingCurrentClassLoader does not throw ACE */ + @SuppressWarnings("removal") public void testPrivilegedCallableUsingCCLWithPrivs() throws Exception { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { @@ -431,6 +440,7 @@ public class ExecutorsTest extends JSR16 /** * Without permissions, calling privilegedCallable throws ACE */ + @SuppressWarnings("removal") public void testPrivilegedCallableWithNoPrivs() throws Exception { // Avoid classloader-related SecurityExceptions in swingui.TestRunner Executors.privilegedCallable(new CheckCCL()); @@ -439,7 +449,7 @@ public class ExecutorsTest extends JSR16 public void realRun() throws Exception { if (System.getSecurityManager() == null) return; - Callable task = Executors.privilegedCallable(new CheckCCL()); + Callable task = Executors.privilegedCallable(new CheckCCL()); try { task.call(); shouldThrow(); @@ -503,6 +513,7 @@ public class ExecutorsTest extends JSR16 /** * With permissions, calling privilegedCallable succeeds */ + @SuppressWarnings("removal") public void testPrivilegedCallableWithPrivs() throws Exception { Runnable r = new CheckedRunnable() { public void realRun() throws Exception { @@ -518,7 +529,7 @@ public class ExecutorsTest extends JSR16 * callable(Runnable) returns null when called */ public void testCallable1() throws Exception { - Callable c = Executors.callable(new NoOpRunnable()); + Callable c = Executors.callable(new NoOpRunnable()); assertNull(c.call()); } @@ -526,7 +537,7 @@ public class ExecutorsTest extends JSR16 * callable(Runnable, result) returns result when called */ public void testCallable2() throws Exception { - Callable c = Executors.callable(new NoOpRunnable(), one); + Callable c = Executors.callable(new NoOpRunnable(), one); assertSame(one, c.call()); } @@ -534,7 +545,7 @@ public class ExecutorsTest extends JSR16 * callable(PrivilegedAction) returns its result when called */ public void testCallable3() throws Exception { - Callable c = Executors.callable(new PrivilegedAction() { + Callable c = Executors.callable(new PrivilegedAction() { public Object run() { return one; }}); assertSame(one, c.call()); } @@ -543,7 +554,7 @@ public class ExecutorsTest extends JSR16 * callable(PrivilegedExceptionAction) returns its result when called */ public void testCallable4() throws Exception { - Callable c = Executors.callable(new PrivilegedExceptionAction() { + Callable c = Executors.callable(new PrivilegedExceptionAction() { public Object run() { return one; }}); assertSame(one, c.call()); } @@ -553,7 +564,7 @@ public class ExecutorsTest extends JSR16 */ public void testCallableNPE1() { try { - Callable unused = Executors.callable((Runnable) null); + Callable unused = Executors.callable((Runnable) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -563,7 +574,7 @@ public class ExecutorsTest extends JSR16 */ public void testCallableNPE2() { try { - Callable unused = Executors.callable((Runnable) null, one); + Callable unused = Executors.callable((Runnable) null, one); shouldThrow(); } catch (NullPointerException success) {} } @@ -573,7 +584,7 @@ public class ExecutorsTest extends JSR16 */ public void testCallableNPE3() { try { - Callable unused = Executors.callable((PrivilegedAction) null); + Callable unused = Executors.callable((PrivilegedAction) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -583,7 +594,7 @@ public class ExecutorsTest extends JSR16 */ public void testCallableNPE4() { try { - Callable unused = Executors.callable((PrivilegedExceptionAction) null); + Callable unused = Executors.callable((PrivilegedExceptionAction) null); shouldThrow(); } catch (NullPointerException success) {} } @@ -617,6 +628,7 @@ public class ExecutorsTest extends JSR16 /** * privilegedCallable(callable).toString() contains toString of wrapped task */ + @SuppressWarnings("removal") public void testPrivilegedCallable_toString() { if (testImplementationDetails) { Callable c = () -> ""; @@ -631,6 +643,7 @@ public class ExecutorsTest extends JSR16 * privilegedCallableUsingCurrentClassLoader(callable).toString() * contains toString of wrapped task */ + @SuppressWarnings("removal") public void testPrivilegedCallableUsingCurrentClassLoader_toString() { if (testImplementationDetails) { Callable c = () -> "";