Skip to main content

Problem:

  • Product Name: VisiBroker
  • Product Component: IDL2JAVA
  • Product Version: 6.5 SP14 and later
  • Platform/ OS version: All platforms

VisiBroker's idl2java tool complies to "Section 4.18.2 Complex IDL types" of the OMG IDL to Java Language Mapping specification version 1.3, which states that:

"Typedefs for types that are neither arrays nor sequences are "unwound" to their original type until a simple IDL type or user-defined IDL type (of the non typedef variety) is encountered. Holder classes are generated for sequence and array typedefs only. The "unwound" type"s Holder class is used for the other cases. No holder class is generated for a typedef of a typedef. "

An example of an IDL file (named employee.idl) is shown below:

module Employee {
  struct EmpName {
    string first;
    string last;
  };
  typedef sequence<EmpName> EmployeeSeq;
  typedef EmployeeSeq ListOfEmployee;
};

This IDL file can be compiled by executing the command "idl2java employee.idl".

Prior to VisiBroker 6.5 SP14, the following files will be generated by idl2java:

  • EmpNameHelper.java
  • EmpNameHolder.java
  • EmpName.java
  • EmployeeSeqHelper.java
  • EmployeeSeqHolder.java
  • ListOfEmployeeHelper.java
  • ListOfEmployeeHolder.java

However, the last file, ListOfEmployeeHolder.java, should not be generated in order to comply with the OMG specification. The IDL declaration uses a typedef of "EmployeeSeq" which is also a typedef of "sequence". It was implemented in CR8956 in the following VisiBroker versions:

1. VisiBroker 6.5 Service Pack 14

2. VisiBroker 7.0 Service Pack 2

3. VisIBroker 8.0

Resolution:

For an existing application which uses those Holder classes, there is a need to explicitly generate those files when using the latest versions of VisiBroker to eliminate compilation errors.

To minimize code change, one way to generate those Holder classes is to modify the IDL such that a typedef of a typedef is avoided.

The example IDL above can be modified as follows:

module Employee {
  struct EmpName {
    string first;
    string last;
  };
  typedef sequence<EmpName> EmployeeSeq;
  typedef sequence<EmpName> ListOfEmployee;
};

This will generate the file "ListOfEmployeeHolder.java" as intended. The above method is the recommended way to resolve compilation issues using VB6.5 P14 and later versions of VisiBroker.

However, there can be some cases which restrict the modification of the IDL file or the modification of IDL is not the best option. VisiBroker has added the flag "-holder" to idl2java so that these Holder classes are generated. It mimics the behavior of idl2java prior to VB6.5 SP14. This was implemented in CR10059.

Compiling the original IDL by executing "idl2java -holder employee.idl" will generate the file ListOfEmployeeHolder.java.

The "-holder" flag was released as a hotfix after VB6.5 SP14.  The fix is already incorporated in the latest Service Packs of VB7.0, VB8.0 and VB8.5.


Related Article: [VBJ] idl2java did not resolve to the most basic type for complex idl datatype in VBJ 6.5

 

#Security
#idl2java
#VisiBroker