JDK-4209652 : Put recursive exception handling (ala InvocationTargetException) into Throwable!
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.1.5,1.2.0,1.3.0
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-02-08
  • Updated: 2000-10-28
  • Resolved: 2000-10-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description

Name: krT82822			Date: 02/08/99


It seems that lots of exceptions need support for "internal" or "child" exceptions ala InvocationTargetException. For instance, you often have to
catch exceptions of one type and re-throw them as another. If this functionality was built into Throwable, it would mean that I (and lots of others)
wouldn't have to make incompatible implementations of this functionality. For example, the OO-RDBMS mapping product we're using (TOPLink)
implements this in their TOPLinkException, and so do we in our code. However, using this is a nightmare because the exception handling code
has to support each type of exception differently.

Note also that this could provide another, even more useful feature - the ability to avoid the "got an silly exception in a finally clause which blows
away the important exception I had in the first place" which is pointed out in the Java book "Thinking in Java" by Bruce Eckel (www.bruceeckel.com).
Simply append any exceptions found whilst processing the original exception as "sub" exceptions using the mechanism outlined above and I belive
you have avoided the problem. Of course, how the VM would actually handle that may be harder but thats your job, huh?

:-)
(Review ID: 52287)
======================================================================

Name: rlT66838			Date: 08/10/99


In fact this particular one is just an instance of a more general
need to have the JDK exceptions carry useful information about what
caused them and to make that information available programatically.

It would improve error handling to be able to
find out from a ClassCastException what class
(or interface) the cast was to and what class
it was from. Something like:

public Class targetClass();
public Class sourceClass();

or maybe just return Strings with the class name
and folks can Class.forName() them if they need
to.

P.S. I realize that the message currently returns
the name of the class the cast was from. But
that's not part of the contract.

Another thought: you might need to make these
methods possibly return null if the class isn't
known. But since most ClassCastExceptions should
be generated by the VM and it certainly knows both
classes.
(Review ID: 25234)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin merlin-beta FIXED IN: merlin merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

EVALUATION If I understand what is meant by "internal" exceptions correctly, they are often needed in order to permit static typechecking. In some APIs, e.g., reflection, part of the functionality may be delegated to code that is entirely unknown at compile-time, thus the set of possible exceptions is open-ended. Using an internal exception allows the set of exceptions that we do know to expect at compile-time to be explicitly declared, providing tighter static typing than simply declaring "throws Throwable". william.maddox@Eng 1999-02-12 I could be wrong, but I suspect this happens mostly to sophisticated users, and is NOT all that frequent relative to all users of Java. I doubt if adding this either as a special class or (worse) by modifying Throwable is justified. It just seems like creeping featurism. gilad.bracha@eng 1999-02-16 I think that this is a good idea; it's not really adding a new feature, but providing a quality abstraction for one that already exists. In practice, I believe that it will increase the quality of information available after an exception is thrown. joshua.bloch@Eng 1999-08-17 This is now the draft feature list for Merlin as 4293532 graham.hamilton@Eng 2000-03-03
17-08-1999