5 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
6 |
|
*/ |
7 |
|
|
8 |
– |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
9 |
– |
|
8 |
|
import java.lang.invoke.MethodHandles; |
9 |
|
import java.lang.invoke.VarHandle; |
10 |
|
import java.util.concurrent.CountDownLatch; |
41 |
|
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); |
42 |
|
boolean haveSecurityManager = (System.getSecurityManager() != null); |
43 |
|
CountDownLatch taskStarted = new CountDownLatch(1); |
44 |
+ |
ClassLoader classLoaderDistinctFromSystemClassLoader |
45 |
+ |
= ClassLoader.getPlatformClassLoader(); |
46 |
+ |
assertNotSame(classLoaderDistinctFromSystemClassLoader, |
47 |
+ |
systemClassLoader); |
48 |
|
Runnable runInCommonPool = () -> { |
49 |
|
taskStarted.countDown(); |
50 |
|
assertTrue(ForkJoinTask.inForkJoinPool()); |
58 |
|
assertThrows( |
59 |
|
SecurityException.class, |
60 |
|
() -> System.getProperty("foo"), |
61 |
< |
() -> Thread.currentThread().setContextClassLoader(null)); |
61 |
> |
() -> Thread.currentThread().setContextClassLoader( |
62 |
> |
classLoaderDistinctFromSystemClassLoader)); |
63 |
|
// TODO ? |
64 |
|
// if (haveSecurityManager |
65 |
|
// && Thread.currentThread().getClass().getSimpleName() |
69 |
|
Future<?> f = ForkJoinPool.commonPool().submit(runInCommonPool); |
70 |
|
// Ensure runInCommonPool is truly running in the common pool, |
71 |
|
// by giving this thread no opportunity to "help" on get(). |
72 |
< |
assertTrue(taskStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
72 |
> |
await(taskStarted); |
73 |
|
assertNull(f.get()); |
74 |
|
} |
75 |
|
|