ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.247 by jsr166, Sun Jul 22 21:37:31 2018 UTC vs.
Revision 1.271 by jsr166, Sat Feb 1 18:52:17 2020 UTC

# Line 49 | Line 49 | import java.io.ByteArrayOutputStream;
49   import java.io.ObjectInputStream;
50   import java.io.ObjectOutputStream;
51   import java.lang.management.ManagementFactory;
52 + import java.lang.management.LockInfo;
53   import java.lang.management.ThreadInfo;
54   import java.lang.management.ThreadMXBean;
55   import java.lang.reflect.Constructor;
# Line 117 | Line 118 | import junit.framework.TestSuite;
118   *
119   * <ol>
120   *
121 < * <li>All assertions in code running in generated threads must use
122 < * the forms {@link #threadFail}, {@link #threadAssertTrue}, {@link
123 < * #threadAssertEquals}, or {@link #threadAssertNull}, (not
124 < * {@code fail}, {@code assertTrue}, etc.) It is OK (but not
125 < * particularly recommended) for other code to use these forms too.
126 < * Only the most typically used JUnit assertion methods are defined
127 < * this way, but enough to live with.
121 > * <li>All code not running in the main test thread (manually spawned threads
122 > * or the common fork join pool) must be checked for failure (and completion!).
123 > * Mechanisms that can be used to ensure this are:
124 > *   <ol>
125 > *   <li>Signalling via a synchronizer like AtomicInteger or CountDownLatch
126 > *    that the task completed normally, which is checked before returning from
127 > *    the test method in the main thread.
128 > *   <li>Using the forms {@link #threadFail}, {@link #threadAssertTrue},
129 > *    or {@link #threadAssertNull}, (not {@code fail}, {@code assertTrue}, etc.)
130 > *    Only the most typically used JUnit assertion methods are defined
131 > *    this way, but enough to live with.
132 > *   <li>Recording failure explicitly using {@link #threadUnexpectedException}
133 > *    or {@link #threadRecordFailure}.
134 > *   <li>Using a wrapper like CheckedRunnable that uses one the mechanisms above.
135 > *   </ol>
136   *
137   * <li>If you override {@link #setUp} or {@link #tearDown}, make sure
138   * to invoke {@code super.setUp} and {@code super.tearDown} within
# Line 235 | Line 244 | public class JSR166TestCase extends Test
244          }
245      }
246  
247 +    private static final ThreadMXBean THREAD_MXBEAN
248 +        = ManagementFactory.getThreadMXBean();
249 +
250      /**
251       * The scaling factor to apply to standard delays used in tests.
252       * May be initialized from any of:
# Line 276 | Line 288 | public class JSR166TestCase extends Test
288      static volatile TestCase currentTestCase;
289      // static volatile int currentRun = 0;
290      static {
291 <        Runnable checkForWedgedTest = new Runnable() { public void run() {
291 >        Runnable wedgedTestDetector = new Runnable() { public void run() {
292              // Avoid spurious reports with enormous runsPerTest.
293              // A single test case run should never take more than 1 second.
294              // But let's cap it at the high end too ...
295 <            final int timeoutMinutes =
296 <                Math.min(15, Math.max(runsPerTest / 60, 1));
295 >            final int timeoutMinutesMin = Math.max(runsPerTest / 60, 1)
296 >                * Math.max((int) delayFactor, 1);
297 >            final int timeoutMinutes = Math.min(15, timeoutMinutesMin);
298              for (TestCase lastTestCase = currentTestCase;;) {
299                  try { MINUTES.sleep(timeoutMinutes); }
300                  catch (InterruptedException unexpected) { break; }
# Line 301 | Line 314 | public class JSR166TestCase extends Test
314                  }
315                  lastTestCase = currentTestCase;
316              }}};
317 <        Thread thread = new Thread(checkForWedgedTest, "checkForWedgedTest");
317 >        Thread thread = new Thread(wedgedTestDetector, "WedgedTestDetector");
318          thread.setDaemon(true);
319          thread.start();
320      }
# Line 345 | Line 358 | public class JSR166TestCase extends Test
358              // Never report first run of any test; treat it as a
359              // warmup run, notably to trigger all needed classloading,
360              if (i > 0)
361 <                System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
361 >                System.out.printf("%s: %d%n", toString(), elapsedMillis);
362          }
363      }
364  
# Line 452 | Line 465 | public class JSR166TestCase extends Test
465      public static boolean atLeastJava9()  { return JAVA_CLASS_VERSION >= 53.0; }
466      public static boolean atLeastJava10() { return JAVA_CLASS_VERSION >= 54.0; }
467      public static boolean atLeastJava11() { return JAVA_CLASS_VERSION >= 55.0; }
468 +    public static boolean atLeastJava12() { return JAVA_CLASS_VERSION >= 56.0; }
469 +    public static boolean atLeastJava13() { return JAVA_CLASS_VERSION >= 57.0; }
470 +    public static boolean atLeastJava14() { return JAVA_CLASS_VERSION >= 58.0; }
471 +    public static boolean atLeastJava15() { return JAVA_CLASS_VERSION >= 59.0; }
472 +    public static boolean atLeastJava16() { return JAVA_CLASS_VERSION >= 60.0; }
473 +    public static boolean atLeastJava17() { return JAVA_CLASS_VERSION >= 61.0; }
474  
475      /**
476       * Collects all JSR166 unit tests as one suite.
# Line 503 | Line 522 | public class JSR166TestCase extends Test
522              ExecutorsTest.suite(),
523              ExecutorCompletionServiceTest.suite(),
524              FutureTaskTest.suite(),
525 +            HashtableTest.suite(),
526              LinkedBlockingDequeTest.suite(),
527              LinkedBlockingQueueTest.suite(),
528              LinkedListTest.suite(),
# Line 542 | Line 562 | public class JSR166TestCase extends Test
562                  "HashMapTest",
563                  "LinkedBlockingDeque8Test",
564                  "LinkedBlockingQueue8Test",
565 +                "LinkedHashMapTest",
566                  "LongAccumulatorTest",
567                  "LongAdderTest",
568                  "SplittableRandomTest",
# Line 640 | Line 661 | public class JSR166TestCase extends Test
661      public static long MEDIUM_DELAY_MS;
662      public static long LONG_DELAY_MS;
663  
664 +    /**
665 +     * A delay significantly longer than LONG_DELAY_MS.
666 +     * Use this in a thread that is waited for via awaitTermination(Thread).
667 +     */
668 +    public static long LONGER_DELAY_MS;
669 +
670      private static final long RANDOM_TIMEOUT;
671      private static final long RANDOM_EXPIRED_TIMEOUT;
672      private static final TimeUnit RANDOM_TIMEUNIT;
# Line 668 | Line 695 | public class JSR166TestCase extends Test
695      static TimeUnit randomTimeUnit() { return RANDOM_TIMEUNIT; }
696  
697      /**
698 +     * Returns a random boolean; a "coin flip".
699 +     */
700 +    static boolean randomBoolean() {
701 +        return ThreadLocalRandom.current().nextBoolean();
702 +    }
703 +
704 +    /**
705 +     * Returns a random element from given choices.
706 +     */
707 +    <T> T chooseRandomly(List<T> choices) {
708 +        return choices.get(ThreadLocalRandom.current().nextInt(choices.size()));
709 +    }
710 +
711 +    /**
712 +     * Returns a random element from given choices.
713 +     */
714 +    <T> T chooseRandomly(T... choices) {
715 +        return choices[ThreadLocalRandom.current().nextInt(choices.length)];
716 +    }
717 +
718 +    /**
719       * Returns the shortest timed delay. This can be scaled up for
720       * slow machines using the jsr166.delay.factor system property,
721       * or via jtreg's -timeoutFactor: flag.
# Line 685 | Line 733 | public class JSR166TestCase extends Test
733          SMALL_DELAY_MS  = SHORT_DELAY_MS * 5;
734          MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10;
735          LONG_DELAY_MS   = SHORT_DELAY_MS * 200;
736 +        LONGER_DELAY_MS = 2 * LONG_DELAY_MS;
737      }
738  
739      private static final long TIMEOUT_DELAY_MS
# Line 723 | Line 772 | public class JSR166TestCase extends Test
772       */
773      public void threadRecordFailure(Throwable t) {
774          System.err.println(t);
775 <        dumpTestThreads();
776 <        threadFailure.compareAndSet(null, t);
775 >        if (threadFailure.compareAndSet(null, t))
776 >            dumpTestThreads();
777      }
778  
779      public void setUp() {
# Line 1045 | Line 1094 | public class JSR166TestCase extends Test
1094          }
1095      }
1096  
1097 +    /** Returns true if thread info might be useful in a thread dump. */
1098 +    static boolean threadOfInterest(ThreadInfo info) {
1099 +        final String name = info.getThreadName();
1100 +        String lockName;
1101 +        if (name == null)
1102 +            return true;
1103 +        if (name.equals("Signal Dispatcher")
1104 +            || name.equals("WedgedTestDetector"))
1105 +            return false;
1106 +        if (name.equals("Reference Handler")) {
1107 +            // Reference Handler stacktrace changed in JDK-8156500
1108 +            StackTraceElement[] stackTrace; String methodName;
1109 +            if ((stackTrace = info.getStackTrace()) != null
1110 +                && stackTrace.length > 0
1111 +                && (methodName = stackTrace[0].getMethodName()) != null
1112 +                && methodName.equals("waitForReferencePendingList"))
1113 +                return false;
1114 +            // jdk8 Reference Handler stacktrace
1115 +            if ((lockName = info.getLockName()) != null
1116 +                && lockName.startsWith("java.lang.ref"))
1117 +                return false;
1118 +        }
1119 +        if ((name.equals("Finalizer") || name.equals("Common-Cleaner"))
1120 +            && (lockName = info.getLockName()) != null
1121 +            && lockName.startsWith("java.lang.ref"))
1122 +            return false;
1123 +        if (name.startsWith("ForkJoinPool.commonPool-worker")
1124 +            && (lockName = info.getLockName()) != null
1125 +            && lockName.startsWith("java.util.concurrent.ForkJoinPool"))
1126 +            return false;
1127 +        return true;
1128 +    }
1129 +
1130      /**
1131       * A debugging tool to print stack traces of most threads, as jstack does.
1132       * Uninteresting threads are filtered out.
# Line 1059 | Line 1141 | public class JSR166TestCase extends Test
1141              }
1142          }
1143  
1062        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
1144          System.err.println("------ stacktrace dump start ------");
1145 <        for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) {
1146 <            final String name = info.getThreadName();
1147 <            String lockName;
1067 <            if ("Signal Dispatcher".equals(name))
1068 <                continue;
1069 <            if ("Reference Handler".equals(name)
1070 <                && (lockName = info.getLockName()) != null
1071 <                && lockName.startsWith("java.lang.ref.Reference$Lock"))
1072 <                continue;
1073 <            if ("Finalizer".equals(name)
1074 <                && (lockName = info.getLockName()) != null
1075 <                && lockName.startsWith("java.lang.ref.ReferenceQueue$Lock"))
1076 <                continue;
1077 <            if ("checkForWedgedTest".equals(name))
1078 <                continue;
1079 <            System.err.print(info);
1080 <        }
1145 >        for (ThreadInfo info : THREAD_MXBEAN.dumpAllThreads(true, true))
1146 >            if (threadOfInterest(info))
1147 >                System.err.print(info);
1148          System.err.println("------ stacktrace dump end ------");
1149  
1150          if (sm != null) System.setSecurityManager(sm);
# Line 1104 | Line 1171 | public class JSR166TestCase extends Test
1171      }
1172  
1173      /**
1174 +     * Returns the thread's blocker's class name, if any, else null.
1175 +     */
1176 +    String blockerClassName(Thread thread) {
1177 +        ThreadInfo threadInfo; LockInfo lockInfo;
1178 +        if ((threadInfo = THREAD_MXBEAN.getThreadInfo(thread.getId(), 0)) != null
1179 +            && (lockInfo = threadInfo.getLockInfo()) != null)
1180 +            return lockInfo.getClassName();
1181 +        return null;
1182 +    }
1183 +
1184 +    /**
1185       * Checks that future.get times out, with the default timeout of
1186       * {@code timeoutMillis()}.
1187       */
# Line 1122 | Line 1200 | public class JSR166TestCase extends Test
1200          } catch (TimeoutException success) {
1201          } catch (Exception fail) {
1202              threadUnexpectedException(fail);
1203 <        } finally { future.cancel(true); }
1203 >        }
1204          assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
1205 +        assertFalse(future.isDone());
1206      }
1207  
1208      /**
# Line 1291 | Line 1370 | public class JSR166TestCase extends Test
1370      /**
1371       * Spin-waits up to the specified number of milliseconds for the given
1372       * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING.
1373 +     * @param waitingForGodot if non-null, an additional condition to satisfy
1374       */
1375 <    void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) {
1376 <        long startTime = 0L;
1377 <        for (;;) {
1378 <            Thread.State s = thread.getState();
1379 <            if (s == Thread.State.BLOCKED ||
1380 <                s == Thread.State.WAITING ||
1381 <                s == Thread.State.TIMED_WAITING)
1382 <                return;
1383 <            else if (s == Thread.State.TERMINATED)
1375 >    void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis,
1376 >                                       Callable<Boolean> waitingForGodot) {
1377 >        for (long startTime = 0L;;) {
1378 >            switch (thread.getState()) {
1379 >            default: break;
1380 >            case BLOCKED: case WAITING: case TIMED_WAITING:
1381 >                try {
1382 >                    if (waitingForGodot == null || waitingForGodot.call())
1383 >                        return;
1384 >                } catch (Throwable fail) { threadUnexpectedException(fail); }
1385 >                break;
1386 >            case TERMINATED:
1387                  fail("Unexpected thread termination");
1388 <            else if (startTime == 0L)
1388 >            }
1389 >
1390 >            if (startTime == 0L)
1391                  startTime = System.nanoTime();
1392              else if (millisElapsedSince(startTime) > timeoutMillis) {
1393 <                threadAssertTrue(thread.isAlive());
1394 <                fail("timed out waiting for thread to enter wait state");
1393 >                assertTrue(thread.isAlive());
1394 >                if (waitingForGodot == null
1395 >                    || thread.getState() == Thread.State.RUNNABLE)
1396 >                    fail("timed out waiting for thread to enter wait state");
1397 >                else
1398 >                    fail("timed out waiting for condition, thread state="
1399 >                         + thread.getState());
1400              }
1401              Thread.yield();
1402          }
# Line 1314 | Line 1404 | public class JSR166TestCase extends Test
1404  
1405      /**
1406       * Spin-waits up to the specified number of milliseconds for the given
1407 <     * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING,
1318 <     * and additionally satisfy the given condition.
1407 >     * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING.
1408       */
1409 <    void waitForThreadToEnterWaitState(
1410 <        Thread thread, long timeoutMillis, Callable<Boolean> waitingForGodot) {
1322 <        long startTime = 0L;
1323 <        for (;;) {
1324 <            Thread.State s = thread.getState();
1325 <            if (s == Thread.State.BLOCKED ||
1326 <                s == Thread.State.WAITING ||
1327 <                s == Thread.State.TIMED_WAITING) {
1328 <                try {
1329 <                    if (waitingForGodot.call())
1330 <                        return;
1331 <                } catch (Throwable fail) { threadUnexpectedException(fail); }
1332 <            }
1333 <            else if (s == Thread.State.TERMINATED)
1334 <                fail("Unexpected thread termination");
1335 <            else if (startTime == 0L)
1336 <                startTime = System.nanoTime();
1337 <            else if (millisElapsedSince(startTime) > timeoutMillis) {
1338 <                threadAssertTrue(thread.isAlive());
1339 <                fail("timed out waiting for thread to enter wait state");
1340 <            }
1341 <            Thread.yield();
1342 <        }
1409 >    void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) {
1410 >        waitForThreadToEnterWaitState(thread, timeoutMillis, null);
1411      }
1412  
1413      /**
# Line 1347 | Line 1415 | public class JSR166TestCase extends Test
1415       * enter a wait state: BLOCKED, WAITING, or TIMED_WAITING.
1416       */
1417      void waitForThreadToEnterWaitState(Thread thread) {
1418 <        waitForThreadToEnterWaitState(thread, LONG_DELAY_MS);
1418 >        waitForThreadToEnterWaitState(thread, LONG_DELAY_MS, null);
1419      }
1420  
1421      /**
# Line 1355 | Line 1423 | public class JSR166TestCase extends Test
1423       * enter a wait state: BLOCKED, WAITING, or TIMED_WAITING,
1424       * and additionally satisfy the given condition.
1425       */
1426 <    void waitForThreadToEnterWaitState(
1427 <        Thread thread, Callable<Boolean> waitingForGodot) {
1426 >    void waitForThreadToEnterWaitState(Thread thread,
1427 >                                       Callable<Boolean> waitingForGodot) {
1428          waitForThreadToEnterWaitState(thread, LONG_DELAY_MS, waitingForGodot);
1429      }
1430  
1431      /**
1432 +     * Spin-waits up to LONG_DELAY_MS milliseconds for the current thread to
1433 +     * be interrupted.  Clears the interrupt status before returning.
1434 +     */
1435 +    void awaitInterrupted() {
1436 +        for (long startTime = 0L; !Thread.interrupted(); ) {
1437 +            if (startTime == 0L)
1438 +                startTime = System.nanoTime();
1439 +            else if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1440 +                fail("timed out waiting for thread interrupt");
1441 +            Thread.yield();
1442 +        }
1443 +    }
1444 +
1445 +    /**
1446       * Returns the number of milliseconds since time given by
1447       * startNanoTime, which must have been previously returned from a
1448       * call to {@link System#nanoTime()}.
# Line 1369 | Line 1451 | public class JSR166TestCase extends Test
1451          return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime);
1452      }
1453  
1372 //     void assertTerminatesPromptly(long timeoutMillis, Runnable r) {
1373 //         long startTime = System.nanoTime();
1374 //         try {
1375 //             r.run();
1376 //         } catch (Throwable fail) { threadUnexpectedException(fail); }
1377 //         if (millisElapsedSince(startTime) > timeoutMillis/2)
1378 //             throw new AssertionError("did not return promptly");
1379 //     }
1380
1381 //     void assertTerminatesPromptly(Runnable r) {
1382 //         assertTerminatesPromptly(LONG_DELAY_MS/2, r);
1383 //     }
1384
1454      /**
1455       * Checks that timed f.get() returns the expected value, and does not
1456       * wait for the timeout to elapse before returning.
# Line 1412 | Line 1481 | public class JSR166TestCase extends Test
1481      }
1482  
1483      /**
1484 +     * Returns a new started daemon Thread running the given action,
1485 +     * wrapped in a CheckedRunnable.
1486 +     */
1487 +    Thread newStartedThread(Action action) {
1488 +        return newStartedThread(checkedRunnable(action));
1489 +    }
1490 +
1491 +    /**
1492       * Waits for the specified time (in milliseconds) for the thread
1493       * to terminate (using {@link Thread#join(long)}), else interrupts
1494       * the thread (in the hope that it may terminate later) and fails.
1495       */
1496 <    void awaitTermination(Thread t, long timeoutMillis) {
1496 >    void awaitTermination(Thread thread, long timeoutMillis) {
1497          try {
1498 <            t.join(timeoutMillis);
1498 >            thread.join(timeoutMillis);
1499          } catch (InterruptedException fail) {
1500              threadUnexpectedException(fail);
1501 <        } finally {
1502 <            if (t.getState() != Thread.State.TERMINATED) {
1503 <                t.interrupt();
1504 <                threadFail("timed out waiting for thread to terminate");
1501 >        }
1502 >        if (thread.getState() != Thread.State.TERMINATED) {
1503 >            String detail = String.format(
1504 >                    "timed out waiting for thread to terminate, thread=%s, state=%s" ,
1505 >                    thread, thread.getState());
1506 >            try {
1507 >                threadFail(detail);
1508 >            } finally {
1509 >                // Interrupt thread __after__ having reported its stack trace
1510 >                thread.interrupt();
1511              }
1512          }
1513      }
# Line 1452 | Line 1535 | public class JSR166TestCase extends Test
1535          }
1536      }
1537  
1538 +    Runnable checkedRunnable(Action action) {
1539 +        return new CheckedRunnable() {
1540 +            public void realRun() throws Throwable {
1541 +                action.run();
1542 +            }};
1543 +    }
1544 +
1545      public abstract class ThreadShouldThrow extends Thread {
1546          protected abstract void realRun() throws Throwable;
1547  
# Line 1464 | Line 1554 | public class JSR166TestCase extends Test
1554          public final void run() {
1555              try {
1556                  realRun();
1467                threadShouldThrow(exceptionClass.getSimpleName());
1557              } catch (Throwable t) {
1558                  if (! exceptionClass.isInstance(t))
1559                      threadUnexpectedException(t);
1560 +                return;
1561              }
1562 +            threadShouldThrow(exceptionClass.getSimpleName());
1563          }
1564      }
1565  
# Line 1478 | Line 1569 | public class JSR166TestCase extends Test
1569          public final void run() {
1570              try {
1571                  realRun();
1481                threadShouldThrow("InterruptedException");
1572              } catch (InterruptedException success) {
1573                  threadAssertFalse(Thread.interrupted());
1574 +                return;
1575              } catch (Throwable fail) {
1576                  threadUnexpectedException(fail);
1577              }
1578 +            threadShouldThrow("InterruptedException");
1579          }
1580      }
1581  
# Line 1495 | Line 1587 | public class JSR166TestCase extends Test
1587                  return realCall();
1588              } catch (Throwable fail) {
1589                  threadUnexpectedException(fail);
1498                return null;
1590              }
1591 <        }
1501 <    }
1502 <
1503 <    public abstract class CheckedInterruptedCallable<T>
1504 <        implements Callable<T> {
1505 <        protected abstract T realCall() throws Throwable;
1506 <
1507 <        public final T call() {
1508 <            try {
1509 <                T result = realCall();
1510 <                threadShouldThrow("InterruptedException");
1511 <                return result;
1512 <            } catch (InterruptedException success) {
1513 <                threadAssertFalse(Thread.interrupted());
1514 <            } catch (Throwable fail) {
1515 <                threadUnexpectedException(fail);
1516 <            }
1517 <            return null;
1591 >            throw new AssertionError("unreached");
1592          }
1593      }
1594  
# Line 1629 | Line 1703 | public class JSR166TestCase extends Test
1703          public String call() { throw new NullPointerException(); }
1704      }
1705  
1632    public class SmallPossiblyInterruptedRunnable extends CheckedRunnable {
1633        protected void realRun() {
1634            try {
1635                delay(SMALL_DELAY_MS);
1636            } catch (InterruptedException ok) {}
1637        }
1638    }
1639
1706      public Runnable possiblyInterruptedRunnable(final long timeoutMillis) {
1707          return new CheckedRunnable() {
1708              protected void realRun() {
# Line 1692 | Line 1758 | public class JSR166TestCase extends Test
1758                  return realCompute();
1759              } catch (Throwable fail) {
1760                  threadUnexpectedException(fail);
1695                return null;
1761              }
1762 +            throw new AssertionError("unreached");
1763          }
1764      }
1765  
# Line 1714 | Line 1780 | public class JSR166TestCase extends Test
1780  
1781          public int await() {
1782              try {
1783 <                return super.await(2 * LONG_DELAY_MS, MILLISECONDS);
1783 >                return super.await(LONGER_DELAY_MS, MILLISECONDS);
1784              } catch (TimeoutException timedOut) {
1785                  throw new AssertionError("timed out");
1786              } catch (Exception fail) {
# Line 1770 | Line 1836 | public class JSR166TestCase extends Test
1836          }
1837      }
1838  
1839 <    void assertImmutable(final Object o) {
1839 >    void assertImmutable(Object o) {
1840          if (o instanceof Collection) {
1841              assertThrows(
1842                  UnsupportedOperationException.class,
1843 <                new Runnable() { public void run() {
1778 <                        ((Collection) o).add(null);}});
1843 >                () -> ((Collection) o).add(null));
1844          }
1845      }
1846  
# Line 1835 | Line 1900 | public class JSR166TestCase extends Test
1900      }
1901  
1902      public void assertThrows(Class<? extends Throwable> expectedExceptionClass,
1903 <                             Runnable... throwingActions) {
1904 <        for (Runnable throwingAction : throwingActions) {
1903 >                             Action... throwingActions) {
1904 >        for (Action throwingAction : throwingActions) {
1905              boolean threw = false;
1906              try { throwingAction.run(); }
1907              catch (Throwable t) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines