Time to put a stop to Thread.stop?
jeroen at sumatra.nl
Tue May 14 15:46:20 UTC 2013
I agree that (ab)using generics is the better way, but that doesn't matter, this trick is much older so it is probably used somewhere and there is no good reason to break it.
I'm fully in favor of removing the ability to throw arbitrary exceptions on other threads. IKVM doesn't support this and I've never seen any code break.
> -----Original Message-----
> From: core-libs-dev-bounces at openjdk.java.net [mailto:core-libs-dev-
> bounces at openjdk.java.net] On Behalf Of Remi Forax
> Sent: Tuesday, May 14, 2013 17:29
> To: core-libs-dev at openjdk.java.net
> Subject: Re: Time to put a stop to Thread.stop?
> On 05/14/2013 04:45 PM, Jeroen Frijters 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.
> This hack doesn't work well because Thread.stop(Throwable) can call the
> security manager.
> Using a raw type to see an Exception as a RuntimeException is a better
> hack, obviously tunnelling the exception in a runtimee one (as a cause)
> is the safe way to do that.
> >> -----Original Message-----
> >> From: core-libs-dev-bounces at openjdk.java.net [mailto:core-libs-dev-
> >> bounces at openjdk.java.net] On Behalf Of Alan Bateman
> >> Sent: Tuesday, May 14, 2013 16:25
> >> To: core-libs-dev
> >> Subject: Time to put a stop to Thread.stop?
> >> I would like to broach the subject of pulling out the implementation
> >> of Thread.stop(Throwable), maybe suspend/resume later. By "pulling
> >> out" I mean changing it to unconditionally throw
> >> As we all know, these methods have been deprecated since 1998 so
> >> that's
> >> 15 years to design out any need for these methods. That said, I
> >> periodically come across code that uses no-arg Thread.stop(). David
> >> Holmes mentioned to me recently that he came across a usage in the
> >> recent past too. I don't think I've ever come across code using
> >> Thread.stop(Throwable) and this one is arguably the most dangerous of
> >> the group.
> >> So I'm curious if anyone has come across a Thread.stop(Throwable)
> >> usage in recent times. Clearly changing this would be a significant
> >> change but the real impact might be close to zero. If we decide this
> >> is the right thing to do then there is a bit of detail to work out,
> that's for later.
> >> -Alan.
More information about the core-libs-dev