Skip to main content

Compile error when including a java serializable exception inside a Java interface extending org.omg.CORBA.UserException

  • February 16, 2013
  • 0 replies
  • 1 view

Problem:

  • Product Name: VisiBroker for Java
  • Product Version: All
  • Product Component: java2idl, java2iiop
  • Platform/OS Version: All
  • JDK/Compiler Version: All

Compile error when including a java serializable exception inside an interface extending org.omg.CORBA.UserException.

An example would be passing java.sql.SQLException inside a java interface that extends org.omg.CORBA.UserException. It is necessary for an IDL to be generated from the java interface to provide proper marshaling help. This leads to the above mentioned probelm.

  1. Exception.idl is created by java2idl from a Java interface that includes java.sql.SQLException as its member:
    #include "javaSQL.idl"
    module Test1 {
      exception myException1 {
        ::java::sql::SQLException javaSQLEx;
        wstring name;
        long id;
      };
    }:
  2. javaSQL.idl is created by following command:
    > java2idl -o javaSQL.idl java.sql.SQLException
  3. Compile Exception.idl with following commands:
    > idl2java javaSQL.idl
    > idl2java -I . Exception.idl
    (java files are generated and placed in Test1 subdirectory)
  4. Now compile the generated java files in Test1 subdirectory:
    > vbjc ./Test1/*.java
    The following error messages are shown:
    ./Test1/myException1Helper.java:64: cannot resolve symbol
    symbol : class SQLExceptionHelper
    location: package sql
    members[0] = new org.omg.CORBA.StructMember("javaSQLEx", java.sql.SQLExcecptionHelper.type(), null);
                                                                                                                         ^
    1 error
  5. In fact, SQLExceptionHelper was not generated by Step 3 idl2java javaSQL.idl

Resolution:


The SQLException valuetype is not an "IDLEntity" that is it has an "RMI:" #pragma ID
in the generated IDL file to signify this and to prevent the idl2java compiler from attempting
to create the java.sql.SQLExceptionHelper class. This avoids attempts to add classes
to java.lang, java.sql packages.

The current design of Visibroker does not allow this method of passing java.sql.SQLException, nor does Visibroker's design in any violation of the CORBA specification.

In fact, since java.sql.SQLException itself is a java serializable object, neither the java2iiop nor the java2idl compiler will generate any helper or holder classes. This is per CORBA specification.

Other methods of passing java.sql.SQLException should be considered, such as passing the java.sql.SQLException inside a Java interface that inherits java.rmi.Remote, or a java class that implements java.io.Serializable.


Author: Henry Hwang

Old KB# 26382

#Security
#VisiBroker
#IIOP