dacapo xalan

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

 



Mark Wielaard wrote:
> On Wed, 2006-03-01 at 10:15 -0800, David Daney wrote:
> 
>>Andrew Haley wrote:
>>
>>>Mark Wielaard writes:
>>> > Does the dacapo xalan work for you with the following patch?
>>> > 
>>> > diff -u -r1.36 ResourceBundle.java
>>> > --- java/util/ResourceBundle.java       23 Oct 2005 17:04:46 -0000      1.36
>>> > +++ java/util/ResourceBundle.java       1 Mar 2006 10:59:59 -0000
>>> > @@ -476,9 +476,7 @@
>>> >         if (ResourceBundle.class.isAssignableFrom(rbClass))
>>> >           bundle = (ResourceBundle) rbClass.newInstance();
>>> >        }
>>> > -    catch (IllegalAccessException ex) {}
>>> > -    catch (InstantiationException ex) {}
>>> > -    catch (ClassNotFoundException ex) {}
>>> > +    catch (Throwable t) { /* Class initialization failed, no valid bundle. */ }
>>>
>>>Are you sure about this?  Do you really want to catch
>>>VirtualMachineError here?
>>
>>Or ThreadDeath, or OutOfMemoryError, or StackOverflowError, or ...
>>
>>Well maybe some of those, but why not just catch those documented in 
>>Class.newInstance() and Class.forName()?  Namely add LinkageError and 
>>ExceptionInInitializerError.  Or maybe Exceptions in general but no 
>>Errors others than those explicitly documented.
> 
> 
> No I wasn't sure :) I just wanted to provide Christian with a quick and
> dirty patch to make sure treating exceptions thrown from a constructor
> as failed initialization of a ResourceBundle class was the thing that
> was going wrong. Jeroen did more testing and fixed it by just catching
> Exception. Unfortunately Class.newInstance() isn't guaranteed to wrap
> exceptions (even declared exceptions) thrown from the default
> constructor in an ExceptionInInitializer. Although that is what JikesRVM
> does, but that is a bug in JikesRVM - a bug that helped counter this bug
> it seems :)
> 

We cannot violate the JLS!  A method that throws a checked exception 
without declaring it is a bug.  If Class.newInstance() throws a checked 
exception other than those that it declares, it is a bug.  We cannot 
violate the JLS for any reason, not even to mimic bugs in other runtimes.


My reading of the specification is:  If the constructor throws an 
exception Class.newInstance must throw InstantiationException.  If the 
Class static initializer throws then ExceptionInInitializerError.

By catching all declared Errors and Exceptions, we should be safe.  If 
we are not, then we should fix Class.newInstance().

David Daney.


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux