12 |
|
* @modules java.management |
13 |
|
* @build * |
14 |
|
* @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase |
15 |
+ |
* @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 -Djsr166.testImplementationDetails=true JSR166TestCase |
16 |
+ |
* @run junit/othervm/timeout=1000 -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -Djava.util.secureRandomSeed=true JSR166TestCase |
17 |
|
*/ |
18 |
|
|
19 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
60 |
|
import java.util.concurrent.RecursiveTask; |
61 |
|
import java.util.concurrent.RejectedExecutionHandler; |
62 |
|
import java.util.concurrent.Semaphore; |
63 |
+ |
import java.util.concurrent.SynchronousQueue; |
64 |
|
import java.util.concurrent.ThreadFactory; |
65 |
|
import java.util.concurrent.ThreadPoolExecutor; |
66 |
|
import java.util.concurrent.TimeoutException; |
522 |
|
// Java9+ test classes |
523 |
|
if (atLeastJava9()) { |
524 |
|
String[] java9TestClassNames = { |
525 |
< |
// Currently empty, but expecting varhandle tests |
525 |
> |
"AtomicBoolean9Test", |
526 |
> |
"AtomicInteger9Test", |
527 |
> |
"AtomicIntegerArray9Test", |
528 |
> |
"AtomicLong9Test", |
529 |
> |
"AtomicLongArray9Test", |
530 |
> |
"AtomicReference9Test", |
531 |
> |
"AtomicReferenceArray9Test", |
532 |
> |
"ExecutorCompletionService9Test", |
533 |
|
}; |
534 |
|
addNamedTestClasses(suite, java9TestClassNames); |
535 |
|
} |
956 |
|
} |
957 |
|
} |
958 |
|
|
959 |
< |
/** Like Runnable, but with the freedom to throw anything */ |
959 |
> |
/** |
960 |
> |
* Like Runnable, but with the freedom to throw anything. |
961 |
> |
* junit folks had the same idea: |
962 |
> |
* http://junit.org/junit5/docs/snapshot/api/org/junit/gen5/api/Executable.html |
963 |
> |
*/ |
964 |
|
interface Action { public void run() throws Throwable; } |
965 |
|
|
966 |
|
/** |
991 |
|
* Uninteresting threads are filtered out. |
992 |
|
*/ |
993 |
|
static void dumpTestThreads() { |
994 |
+ |
SecurityManager sm = System.getSecurityManager(); |
995 |
+ |
if (sm != null) { |
996 |
+ |
try { |
997 |
+ |
System.setSecurityManager(null); |
998 |
+ |
} catch (SecurityException giveUp) { |
999 |
+ |
return; |
1000 |
+ |
} |
1001 |
+ |
} |
1002 |
+ |
|
1003 |
|
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); |
1004 |
|
System.err.println("------ stacktrace dump start ------"); |
1005 |
|
for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) { |
1017 |
|
System.err.print(info); |
1018 |
|
} |
1019 |
|
System.err.println("------ stacktrace dump end ------"); |
1020 |
+ |
|
1021 |
+ |
if (sm != null) System.setSecurityManager(sm); |
1022 |
|
} |
1023 |
|
|
1024 |
|
/** |
1866 |
|
public Runnable runnableThrowing(final RuntimeException ex) { |
1867 |
|
return new Runnable() { public void run() { throw ex; }}; |
1868 |
|
} |
1869 |
+ |
|
1870 |
+ |
/** A reusable thread pool to be shared by tests. */ |
1871 |
+ |
static final ExecutorService cachedThreadPool = |
1872 |
+ |
new ThreadPoolExecutor(0, Integer.MAX_VALUE, |
1873 |
+ |
1000L, MILLISECONDS, |
1874 |
+ |
new SynchronousQueue<Runnable>()); |
1875 |
+ |
|
1876 |
|
} |