-
Bug
-
Resolution: Won't Fix
-
P4
-
8
-
generic
-
generic
SYNOPSIS
--------
Interoperability issue while marshalling (IIOP) an Enum between IBM and Oracle ORB
OPERATING SYSTEMS
-----------------
All
JDK VERSION
-----------
Tested with 7u6
PROBLEM DESCRIPTION from LICENSEE
---------------------------------
There is an interoperability issue between the Oracle and IBM JDK while marshalling an Enum. If an Enum is marshalled by the IBM ORB it cannot be read by Oracle orb, and vice-versa.
We have analysed the problem and found that the Oracle ORB writes the ordinal of the Enum before writing the name of the Enum. The Oracle ORB also expects the ordinal value to be present when reading an Enum from a stream.
As per the OMG specification for Enums, the ordinal values are not required and should not be written to the stream. See Java to IDL Language mapping version. 1.4 <http://www.omg.org/spec/JAV2I/1.4>, page 32:
4.3.5.13 Mapping for java.lang.Enum
The class java.lang,Enum is mapped to OMG IDL following the rules for mapping RMI/IDL value types defined in previous sub clauses, with the exception that the ordinal field is not mapped to an OMG IDL data member.
For example, this class could be mapped to the following OMG IDL:
// IDL
module java {
module lang {
valuetype _Enum ::java::lang::Comparable {
private ::CORBA::WStringValue name_;
::CORBA::WStringValue name ( );
};
#pragma ID _Enum ?RMI:java.lang.Enum:CA9967EE1176F5B3:0000000000000000?
};
};
4.3.5.14 Mapping for Java enum types
Java enum types are mapped to OMG IDL following the rules for mapping RMI/IDL value types defined in previous sub clauses, with the exception that their fields are not mapped to OMG IDL data members.
For example, the Java enum
public enum Direction {
NORTH (0),
SOUTH (180),
EAST (90),
WEST (270) ;
public final int bearing;
Direction (int bearing) {
this.bearing = bearing;
}
}
could be mapped to the following OMG IDL:
// IDL
valuetype Direction: ::java::lang::_Enum ( );
#pragma ID Direction ?RMI:Direction:332C04E72E3DB2A1:0000000000000000?
// IDL
module java {
module lang {
valuetype _Enum ::java::lang::Comparable {
private ::CORBA::WStringValue name_;
::CORBA::WStringValue name ( );
};
#pragma ID _Enum ?RMI:java.lang.Enum:CA9967EE1176F5B3:0000000000000000?
};
};
Another reference:
http://www.omg.org/issues/issue10336.txt
REPRODUCTION INSTRUCTIONS
-------------------------
1. Extract the attached test package
2. Set PATH to IBM JDK *
3. Run: javac -d ./classes ./src/*.java
4. Run: cd ./classes
5. Run: rmic -iiop -classpath . HelloImpl
6. Run: tnameserv -J-showversion -ORBInitialPort 2911
7. Open a new terminal window and cd to testcase folder
8. Set PATH to IBM JDK *
9. Run: java -cp ./classes RServer
10. Open a new terminal window and cd to testcase folder
11. Set PATH to Oracle JDK *
12. Run: java -cp ./classes RClient
* Or vice versa
You will see a MarshalException.
SUGGESTED FIX from LICENSEE
---------------------------
While marshalling Enums don't write the ordinal value, as it is not required by the specification. The ordinal value does not help the reading side to reconstruct the Enum in any way.
--------
Interoperability issue while marshalling (IIOP) an Enum between IBM and Oracle ORB
OPERATING SYSTEMS
-----------------
All
JDK VERSION
-----------
Tested with 7u6
PROBLEM DESCRIPTION from LICENSEE
---------------------------------
There is an interoperability issue between the Oracle and IBM JDK while marshalling an Enum. If an Enum is marshalled by the IBM ORB it cannot be read by Oracle orb, and vice-versa.
We have analysed the problem and found that the Oracle ORB writes the ordinal of the Enum before writing the name of the Enum. The Oracle ORB also expects the ordinal value to be present when reading an Enum from a stream.
As per the OMG specification for Enums, the ordinal values are not required and should not be written to the stream. See Java to IDL Language mapping version. 1.4 <http://www.omg.org/spec/JAV2I/1.4>, page 32:
4.3.5.13 Mapping for java.lang.Enum
The class java.lang,Enum is mapped to OMG IDL following the rules for mapping RMI/IDL value types defined in previous sub clauses, with the exception that the ordinal field is not mapped to an OMG IDL data member.
For example, this class could be mapped to the following OMG IDL:
// IDL
module java {
module lang {
valuetype _Enum ::java::lang::Comparable {
private ::CORBA::WStringValue name_;
::CORBA::WStringValue name ( );
};
#pragma ID _Enum ?RMI:java.lang.Enum:CA9967EE1176F5B3:0000000000000000?
};
};
4.3.5.14 Mapping for Java enum types
Java enum types are mapped to OMG IDL following the rules for mapping RMI/IDL value types defined in previous sub clauses, with the exception that their fields are not mapped to OMG IDL data members.
For example, the Java enum
public enum Direction {
NORTH (0),
SOUTH (180),
EAST (90),
WEST (270) ;
public final int bearing;
Direction (int bearing) {
this.bearing = bearing;
}
}
could be mapped to the following OMG IDL:
// IDL
valuetype Direction: ::java::lang::_Enum ( );
#pragma ID Direction ?RMI:Direction:332C04E72E3DB2A1:0000000000000000?
// IDL
module java {
module lang {
valuetype _Enum ::java::lang::Comparable {
private ::CORBA::WStringValue name_;
::CORBA::WStringValue name ( );
};
#pragma ID _Enum ?RMI:java.lang.Enum:CA9967EE1176F5B3:0000000000000000?
};
};
Another reference:
http://www.omg.org/issues/issue10336.txt
REPRODUCTION INSTRUCTIONS
-------------------------
1. Extract the attached test package
2. Set PATH to IBM JDK *
3. Run: javac -d ./classes ./src/*.java
4. Run: cd ./classes
5. Run: rmic -iiop -classpath . HelloImpl
6. Run: tnameserv -J-showversion -ORBInitialPort 2911
7. Open a new terminal window and cd to testcase folder
8. Set PATH to IBM JDK *
9. Run: java -cp ./classes RServer
10. Open a new terminal window and cd to testcase folder
11. Set PATH to Oracle JDK *
12. Run: java -cp ./classes RClient
* Or vice versa
You will see a MarshalException.
SUGGESTED FIX from LICENSEE
---------------------------
While marshalling Enums don't write the ordinal value, as it is not required by the specification. The ordinal value does not help the reading side to reconstruct the Enum in any way.