test/java/lang/Thread/StopBeforeStart.java

Print this page

        

*** 21,48 **** * questions. */ /* * @test ! * @bug 4519200 * @summary Confirm a Thread.stop before start complies with the spec * @author Pete Soper * * Confirm that a thread that had its stop method invoked before start ! * does properly terminate with expected exception behavior. NOTE that ! * arbitrary application threads could return from their run methods faster ! * than the VM can throw an async exception. */ public class StopBeforeStart { private static final int JOIN_TIMEOUT=10000; ! private class MyThrowable extends Throwable { ! } private class Catcher implements Thread.UncaughtExceptionHandler { ! private boolean nullaryStop; private Throwable theThrowable; private Throwable expectedThrowable; private boolean exceptionThrown; Catcher(boolean nullaryStop) { --- 21,46 ---- * questions. */ /* * @test ! * @bug 4519200 6562203 * @summary Confirm a Thread.stop before start complies with the spec * @author Pete Soper * * Confirm that a thread that had its stop method invoked before start ! * does properly terminate with expected exception behavior. */ public class StopBeforeStart { private static final int JOIN_TIMEOUT=10000; ! @SuppressWarnings("serial") ! private class MyThrowable extends Throwable { } private class Catcher implements Thread.UncaughtExceptionHandler { ! private final boolean nullaryStop; private Throwable theThrowable; private Throwable expectedThrowable; private boolean exceptionThrown; Catcher(boolean nullaryStop) {
*** 108,132 **** Catcher c = new Catcher(nullaryStop); thread.setUncaughtExceptionHandler(c); if (nullaryStop) { ! thread.stop(); } else { ! thread.stop(c.expectedThrowable); } thread.start(); thread.join(JOIN_TIMEOUT); if (thread.getState() != Thread.State.TERMINATED) { ! thread.stop(); // Under high load this could be a false positive throw new RuntimeException(type + " test:" + " app thread did not terminate"); } c.check(type); } } --- 106,140 ---- Catcher c = new Catcher(nullaryStop); thread.setUncaughtExceptionHandler(c); if (nullaryStop) { ! stop(thread); } else { ! stop(thread, c.expectedThrowable); } thread.start(); thread.join(JOIN_TIMEOUT); if (thread.getState() != Thread.State.TERMINATED) { ! stop(thread); // Under high load this could be a false positive throw new RuntimeException(type + " test:" + " app thread did not terminate"); } c.check(type); } + + @SuppressWarnings("deprecation") + void stop(Thread thread) { + thread.stop(); + } + + @SuppressWarnings("deprecation") + void stop(Thread thread, Throwable t) { + thread.stop(t); + } }