classpath
[Top][All Lists]
Advanced

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

Re: java.lang.Class patches


From: Stephen Crawley
Subject: Re: java.lang.Class patches
Date: Mon, 14 Apr 2003 09:40:26 +1000

> > > 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.

Trouble is that this is NOT backwards compatible ... as Jeroen's
example (deleted) thowed

> It should be okay to wrap the exception in this case as the developer
> can only really rely upon documented throws information.  Everything
> else is subject to change without any notice with each JDK release.

Sun tries to avoid changing undocumented behaviour between JDK versions,
especially if it is likely that lots of customer code relies on it.
Changes can make life particularly difficult for 3rd part vendors who
are trying to support a toolset or library across a number of JDK
platforms.

This particular example is one where the risk of breaking customer /
3rd party code would be pretty high.

-- Steve







reply via email to

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