30 |
|
MethodHandles.privateLookupIn(Thread.class, MethodHandles.lookup()) |
31 |
|
.findVarHandle(Thread.class, "contextClassLoader", ClassLoader.class); |
32 |
|
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); |
33 |
< |
//if (System.getSecurityManager() == null) return; |
33 |
> |
boolean haveSecurityManager = (System.getSecurityManager() != null); |
34 |
|
CompletableFuture.runAsync( |
35 |
|
() -> { |
36 |
|
assertSame(systemClassLoader, |
37 |
|
Thread.currentThread().getContextClassLoader()); |
38 |
|
assertSame(systemClassLoader, |
39 |
|
CCL.get(Thread.currentThread())); |
40 |
+ |
if (haveSecurityManager) |
41 |
+ |
assertThrows( |
42 |
+ |
SecurityException.class, |
43 |
+ |
() -> System.getProperty("foo"), |
44 |
+ |
() -> Thread.currentThread().setContextClassLoader(null)); |
45 |
+ |
|
46 |
+ |
// TODO ? |
47 |
+ |
// if (haveSecurityManager |
48 |
+ |
// && Thread.currentThread().getClass().getSimpleName() |
49 |
+ |
// .equals("InnocuousForkJoinWorkerThread")) |
50 |
+ |
// assertThrows(SecurityException.class, /* ?? */); |
51 |
|
}).join(); |
52 |
|
} |
53 |
|
|