[concurrency-interest] Thread interruption protocol:InterruptedException is a "checked" exception, correct?
davidcholmes at aapt.net.au
Wed May 20 15:57:16 EDT 2009
Right - Class.newInstance() was recognized as being broken but deemed
unfixable. Constructor.newInstance() does the right thing.
In general - absent of Class.newInstance() (I vaguely recall there being
another case too ...) or Thread.stop(t) - you should not get an unexpected
Back to the case at hand - which version of the VM are you using? There is a
bug in older Hotspot versions were an interrupt while blocked waiting on the
class initialization monitor, causes InterruptedException to be propagated -
which causes it to be thrown from very unexpected places. In fact I think
this affects all JDK 5 versions of Hotspot.
> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Peter
> Sent: Thursday, 21 May 2009 2:06 AM
> To: Paulo Levi
> Cc: concurrency-interest at cs.oswego.edu; Tom Hawtin
> Subject: Re: [concurrency-interest] Thread interruption
> protocol:InterruptedException is a "checked" exception, correct?
> Oh, I see Constructor.newInstance() as opposed to Class.newInstance().
> But this probably irrelevant here as the stack trace fragment I
> produced in my previous mail appears to show that the exception is
> from Class.forName(String). Also, we call Constructor.newInstance()
> instead of Class.newInstance():
> Class<?> cl = Class.forName(name);
> Constructor constr = cl.getConstructor(argcl);
> return constr.newInstance(args);
> I was just trying to apply Tom's input about passing exception
> checking to the case we appear to have.
> Thanks for making me aware of the difference anyway.
> 2009/5/20 Paulo Levi <i30817 at gmail.com>:
> > You're not reading the javadoc correctly:
> > newInstance()
> > "Note that this method propagates any exception thrown by the nullary
> > constructor, including a checked exception. Use of this method
> > bypasses the compile-time exception checking that would otherwise be
> > performed by the compiler. The Constructor.newInstance method
> avoids this
> > problem by wrapping any exception thrown by the constructor in
> a (checked)
> > InvocationTargetException."
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
More information about the Concurrency-interest