Exceptions

Although SIDL exceptions may be specified as interfaces while Java exceptions are always classes, SIDL exceptions are basically caught and thrown in the native Java manner. A critical difference, as mentioned in the discussion on interface data types, is that a SIDL exception interface's wrapper object must be thrown. While similar from a developer standpoint in that SIDL exceptions are mapped to Java exceptions, the converse is not true. That is, there is no mapping of all Java exceptions to SIDL exceptions.

If an exception is defined in SIDL, Babel will generate code for it. The only difference between native Java and SIDL exceptions is that the SIDL exception constructor cannot take a String argument. Instead, the message must be set with the inherited setNote method and retrieved with getNote. This is important because SIDL exceptions inherit from the Java Exception class. The Java compiler will not give an error if getMessage is called; however, the message returned will not be from SIDL.

Another problem is that regular Java exceptions cannot be passed through the SIDL middleware. Since it is not possible to throw normal, non-SIDL exceptions from a SIDL function implemented in Java, the Java compiler will throw an error if an attempt to do so is made. There are some exceptions. For example, Java runtime exceptions such as ArrayIndexOutOfBoundsException can be thrown. In this case, an error message and stack trace are printed to stderr. In addition, the method returns 0; values of any out or inout arguments are set to NULL; and the program proceeds.

For more information on catching and throwing exceptions, including examples, refer to Subsections 10.3.7 and 10.4.4.



babel-1.4.0
users_guide Last Modified 2008-10-16

http://www.llnl.gov/CASC/components
components@llnl.gov