Time to put a stop to Thread.stop?
Remi Forax
forax at univ-mlv.fr
Tue May 14 15:29:17 UTC 2013
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.
Rémi
>
>> -----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 UnsupportedOperationException.
>>
>> 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
mailing list