Code review request for 6857789: (reflect) Create common superclass of reflective exceptions

Joe Darcy Joe.Darcy at Sun.COM
Mon Jul 13 20:47:21 UTC 2009


On 07/11/09 08:23 AM, Martin Buchholz wrote:
> I have some sympathy for Jason's suggestion.
> The existing parallel hierarchy of classes FooError vs. FooException
> makes some sense.
> NoSuchMethodError is a LinkageError, so why isn't
> NoSuchMethodException a LinkageException?

The JLS and JVMS define linkage of classes and interfaces:

* JLSv3 12.3 
http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.3
* JVMSv2 5.4 
http://java.sun.com/docs/books/jvms/second_edition/html/ConstantPool.doc.html#71418

This process completes before the reflective objects are available.

It is true that defined more broadly most of these exceptions are 
"linkage" problems, like "the method I want isn't there."  However, my 
motivation for the exception name comes from the commonality of the 
exceptions in question being generated by reflective operations, which 
are not defined to be linkage problems.  One could imagine a different 
core reflection design where there was a more direct relation between 
the error and exception conditions or where most of these erroneous 
conditions returned a marker object rather than threw an exception, but 
that is not the API we have to evolve.

-Joe

> I consider reflectively extracting Methods and Fields
> from a Class to be a form of linking, at run-time.
> (But we probably don't want an IncompatibleClassChangeException
> to go with IncompatibleClassChangeError)
>
> InvocationTargetException is not a LinkageException,
> but might be a ReflectiveOperationException.
>
> Martin
>
> On Fri, Jul 10, 2009 at 10:51, Joseph D. Darcy <Joe.Darcy at sun.com 
> <mailto:Joe.Darcy at sun.com>> wrote:
>
>     Jason Mehrens wrote:
>
>         Joe,
>          Wouldn't LinkageException be a better fit than
>         ReflectiveOperationException?  Shorter name and it would mimic
>         the LinkageError inheritance tree introduced in JDK1.0.  I.E.
>         LinkageError -> NoClassDefFoundError, LinkageException ->
>         ClassNotFoundException
>
>
>     "LinkageException" is a shorter name, but these conditions do not
>     indicate there is a problem with linkage.  If there were a linkage
>     program, you wouldn't have the reflective object to work with.
>
>     -Joe
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20090713/24270056/attachment.html>


More information about the core-libs-dev mailing list