classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cp-patches] Re: RFC: Patchfor duplicate entries in serialPersistent


From: Jeroen Frijters
Subject: RE: [cp-patches] Re: RFC: Patchfor duplicate entries in serialPersistentFields
Date: Mon, 12 Dec 2005 09:34:38 +0100

Archie Cobbs wrote:
> Stuart Ballard wrote:
> > Jeroen pointed out to me a while back that you can use 
> generics to throw an
> > unchecked exception:
> 
> There's also a way to do this without using JDK 1.5 stuff, but it's
> even uglier :-)
> 
> Construct a class (dynamically) that has a default constructor
> that simply throws whatever exception you want. Then invoke
> Class.newInstance() on the class.

That doesn't work for all exception types (specifically not the ones
that Class.newInstance declares).

Here's the simplest way to do it:

   Thread.currentThread().stop(someCheckedException);

Thread.stop is deprecated because it is unsafe to throw asynchronous
exception, but that doesn't apply to throwing (synchronous) exceptions
on the current thread, so hopefully most VMs will implement that.

Regards,
Jeroen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]