More About IDL

So far, you've seen how to declare methods and attributes in IDL. You can also declare exceptions, structures, and alternate data types.

Exceptions

You declare an IDL exception using the following form:

exception exceptionName
{
   member declarations
}

As you can see, an exception can have member variables. When you declare member variables for an exception, the IDL-to-Java compiler generates two constructors for the exception, one that takes no parameters and one that takes values for each member variable in the same order that you declared them in the IDL file.

Listing 17.4 shows an example exception declaration.

Code Listing 17.4. Example Exception Declaration
 exception InvalidDataException { string reason; long errorCode; ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.