ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ForkJoinPool9Test.java
Revision: 1.1
Committed: Sun Jan 29 20:19:00 2017 UTC (7 years, 3 months ago) by jsr166
Branch: MAIN
Log Message:
add testCommonPoolThreadContextClassLoader

File Contents

# Content
1 /*
2 * Written by Doug Lea and Martin Buchholz with assistance from
3 * members of JCP JSR-166 Expert Group and released to the public
4 * domain, as explained at
5 * http://creativecommons.org/publicdomain/zero/1.0/
6 */
7
8 import java.lang.invoke.MethodHandles;
9 import java.lang.invoke.VarHandle;
10 import java.util.concurrent.CompletableFuture;
11
12 import junit.framework.Test;
13 import junit.framework.TestSuite;
14
15 public class ForkJoinPool9Test extends JSR166TestCase {
16 public static void main(String[] args) {
17 main(suite(), args);
18 }
19
20 public static Test suite() {
21 return new TestSuite(ForkJoinPool9Test.class);
22 }
23
24 /**
25 * Check handling of common pool thread context class loader
26 */
27 public void testCommonPoolThreadContextClassLoader() throws Throwable {
28 if (!testImplementationDetails) return;
29 VarHandle CCL =
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;
34 CompletableFuture.runAsync(
35 () -> {
36 assertSame(systemClassLoader,
37 Thread.currentThread().getContextClassLoader());
38 assertSame(systemClassLoader,
39 CCL.get(Thread.currentThread()));
40 }).join();
41 }
42
43 }