Time to put a stop to Thread.stop? (original) (raw)

David Holmes david.holmes at oracle.com
Wed May 15 03:17:57 UTC 2013


On 15/05/2013 2:57 AM, Martin Buchholz wrote:

On Tue, May 14, 2013 at 7:45 AM, Jeroen Frijters <jeroen at sumatra.nl> wrote:

IMO Thread.currentThread().stop(new Throwable()) should continue to work. It is not unsafe and it is probably used in a lot of code to workaround the madness that is checked exceptions.

That is truly awful! Why wouldn't people just wrap in a runtime exception ???? Truly, truly awful. :(

If we had to we could special-case for currentThread. :(

There are existing JDK tests that use currentThread().stop to implement the occasionally necessary sneakyThrow.

I suspect there are important uses of unsafe otherThread.stop in the real world, where it is used as a last resort to shut down an "application" running within a java vm, and works reasonably well in practice.

I would dispute that it can work "reasonably well in practice" given the near impossibility of writing async-exception-safe non-trivial Java code. That aside, the proposal is only for the stop(throwable) form which I would not expect to be used for the termination case.

David



More information about the core-libs-dev mailing list