JDK-4432337 : Catching multiple exceptions simultaneously
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.2.2,1.4.2,6,7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2001-03-30
  • Updated: 2014-02-26
  • Resolved: 2011-08-06
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.
JDK 7
7 rcFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description

Name: ssT124754			Date: 03/30/2001


java version "1.2.2"
Classic VM (build JDK-1.2.2-001, native threads, symcjit)

If I need to catch three exceptions, say, NamingException, CreateException and
RemoteException (all of which are descendants of java.lang.Exception) and if I
need to take the same action for them I should not be required to catch them
one after the other. Your compiler should allow me to do something like the
following:

Exception exc;
try
{
   //bunch of stuff
}
catch (NamingException, RemoteException, CreateException exc)
{
    exc.getMessage ();
}
(Review ID: 119838) 
======================================================================

Comments
EVALUATION Maybe.
19-01-2007

EVALUATION I can see why someone would wish for this. However, this just a bit of fancy sugar, and not a very frequent problem. Nor is the burden on the programmer very great: the common action can easily be encapsulated in a method. In most cases, the multiple exceptions might well be organized in hierarchy with a common superclass to avoid this problem. Of course, this might not always be possible. Altogether, an exceedingly minor problem. We'll take it under consideration. gilad.bracha@eng 2001-03-30
30-03-2001