IDL Constructed Types   «Prev  Next»
Lesson 6 Mapping for exceptions, part 1
Objective Describe the Java Class Hierarchy to which IDL Exceptions are Mapped.

Corba exception mapping hierarchy

Both IDL and Java have defined exceptions, and IDL exceptions are mapped to Java exceptions. There are two types of exceptions to consider in CORBA:
  1. system exceptions and
  2. user exceptions.
The Java class hierarchy to which these are mapped is shown in the following diagram:

Diagram that shows exception hierarchy for IDL and Java
1) <<interface>> org.omg.CORBA.portable.IDLEntity
Diagram that shows exception hierarchy for IDL and Java

System exceptions

CORBA has many defined system exceptions, each of which is mapped to a corresponding final Java exception class in the org.omg.CORBA package, which inherits from a common base class, org.omg.CORBA.SystemException. This base class provides a reason string, exception codes, and completion status. This SystemException class inherits from java.lang.RuntimeException so that system exceptions are unchecked.

User-defined exceptions

Exceptions that you define in IDL are mapped to final Java classes that subclass org.omg.CORBA.UserException. UserException, in turn is a subclass of java.lang.Exception. Thus, all user-defined exceptions are checked exceptions. So the exceptions requirements of operations in IDL translate perfectly to exceptions requirements of the corresponding Java methods and all user-defined exceptions must be caught.

Hierarchy depth

Note that the hierarchy is shallow. All the exceptions are subclasses of either SystemException or UserException. There are no ramified chains of inheritance as there often are with regular Java exceptions. This is because exceptions in IDL do not have inheritance; they are not first-rate object-oriented entities like interfaces.
In the next lesson, you will learn more details about mapping for user-defined exceptions and how to use the resulting Java code.

Exception Mapping Hierarchy - Quiz

Click on the Quiz link below to test your knowledge of the exception mapping hierarchy.
Exception Mapping Hierarchy - Quiz