jdk/test/java/util/concurrent/tck/JSR166TestCase.java
changeset 39725 9548f8d846e9
parent 38551 82c48058acc2
child 39879 8d20f3881abf
equal deleted inserted replaced
39724:d935d42f6d93 39725:9548f8d846e9
   546         }
   546         }
   547 
   547 
   548         // Java9+ test classes
   548         // Java9+ test classes
   549         if (atLeastJava9()) {
   549         if (atLeastJava9()) {
   550             String[] java9TestClassNames = {
   550             String[] java9TestClassNames = {
       
   551                 "AtomicBoolean9Test",
       
   552                 "AtomicInteger9Test",
       
   553                 "AtomicIntegerArray9Test",
       
   554                 "AtomicLong9Test",
       
   555                 "AtomicLongArray9Test",
       
   556                 "AtomicReference9Test",
       
   557                 "AtomicReferenceArray9Test",
   551                 "ExecutorCompletionService9Test",
   558                 "ExecutorCompletionService9Test",
   552             };
   559             };
   553             addNamedTestClasses(suite, java9TestClassNames);
   560             addNamedTestClasses(suite, java9TestClassNames);
   554         }
   561         }
   555 
   562 
   973         } catch (InterruptedException fail) {
   980         } catch (InterruptedException fail) {
   974             threadFail("Unexpected InterruptedException");
   981             threadFail("Unexpected InterruptedException");
   975         }
   982         }
   976     }
   983     }
   977 
   984 
   978     /** Like Runnable, but with the freedom to throw anything */
   985     /**
       
   986      * Like Runnable, but with the freedom to throw anything.
       
   987      * junit folks had the same idea:
       
   988      * http://junit.org/junit5/docs/snapshot/api/org/junit/gen5/api/Executable.html
       
   989      */
   979     interface Action { public void run() throws Throwable; }
   990     interface Action { public void run() throws Throwable; }
   980 
   991 
   981     /**
   992     /**
   982      * Runs all the given actions in parallel, failing if any fail.
   993      * Runs all the given actions in parallel, failing if any fail.
   983      * Useful for running multiple variants of tests that are
   994      * Useful for running multiple variants of tests that are
  1004     /**
  1015     /**
  1005      * A debugging tool to print stack traces of most threads, as jstack does.
  1016      * A debugging tool to print stack traces of most threads, as jstack does.
  1006      * Uninteresting threads are filtered out.
  1017      * Uninteresting threads are filtered out.
  1007      */
  1018      */
  1008     static void dumpTestThreads() {
  1019     static void dumpTestThreads() {
       
  1020         SecurityManager sm = System.getSecurityManager();
       
  1021         if (sm != null) {
       
  1022             try {
       
  1023                 System.setSecurityManager(null);
       
  1024             } catch (SecurityException giveUp) {
       
  1025                 return;
       
  1026             }
       
  1027         }
       
  1028 
  1009         ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
  1029         ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
  1010         System.err.println("------ stacktrace dump start ------");
  1030         System.err.println("------ stacktrace dump start ------");
  1011         for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {
  1031         for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {
  1012             String name = info.getThreadName();
  1032             String name = info.getThreadName();
  1013             if ("Signal Dispatcher".equals(name))
  1033             if ("Signal Dispatcher".equals(name))
  1021             if ("checkForWedgedTest".equals(name))
  1041             if ("checkForWedgedTest".equals(name))
  1022                 continue;
  1042                 continue;
  1023             System.err.print(info);
  1043             System.err.print(info);
  1024         }
  1044         }
  1025         System.err.println("------ stacktrace dump end ------");
  1045         System.err.println("------ stacktrace dump end ------");
       
  1046 
       
  1047         if (sm != null) System.setSecurityManager(sm);
  1026     }
  1048     }
  1027 
  1049 
  1028     /**
  1050     /**
  1029      * Checks that thread does not terminate within the default
  1051      * Checks that thread does not terminate within the default
  1030      * millisecond delay of {@code timeoutMillis()}.
  1052      * millisecond delay of {@code timeoutMillis()}.