classpath
[Top][All Lists]
Advanced

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

Re: java.lang.Class patches


From: Archie Cobbs
Subject: Re: java.lang.Class patches
Date: Fri, 11 Apr 2003 10:41:51 -0500 (CDT)

Jeroen Frijters wrote:
> > Could you fix this so that the exception is declared and then 
> > maybe we don't need that native method in VMClass to throw 
> > the exception?
> 
> No, the problem is that *any* exception can be thrown from a constructor
> (and hence from Class.newInstance()). Yet, Class.newInstance() doesn't
> declare "throws Exception" and it can't because that would break
> existing code (wouldn't compile anymore).

Dumb question.. why can't Sun just have Class.newInstance() throw an
InstantiationException, with the original exception chained to the
InstantiationException using initCause(), if the constructor throws
a random exception? The API docs actually imply this, saying that
an InstantiationException is thrown "if the instantiation fails for
some other reason".

Seems like this would be the best way to fix this bug while still
being backwards compatible.

-Archie

__________________________________________________________________________
Archie Cobbs     *     Precision I/O      *     http://www.precisionio.com




reply via email to

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