As you have seen, the mapping of a parameter type is dependent on the IDL type of that parameter as well as the parameter passing mode of that parameter. To know what to expect from the IDL compiler, you should have a good handle on the possible combinations.
View the table below to see an illustration of the mapping from IDL to Java for each primitive type and parameter passing mode.
The columns for in
and return
are the same as are the columns for out
and inout
.
The Java mapping of types in an IDL method signature depends on:
- The IDL data type (e.g.,
short
, long
, string
, etc.).
- The parameter passing mode (
in
, out
, inout
).
- The return type of the method.
The following table summarizes how IDL types are mapped to Java in different method signatures:
IDL Type |
in Parameter Mapping |
out Parameter Mapping |
inout Parameter Mapping |
Return Type Mapping |
short |
short |
ShortHolder |
ShortHolder |
short |
long |
int |
IntHolder |
IntHolder |
int |
long long |
long |
LongHolder |
LongHolder |
long |
unsigned short |
short |
ShortHolder |
ShortHolder |
short |
unsigned long |
int |
IntHolder |
IntHolder |
int |
unsigned long long |
long |
LongHolder |
LongHolder |
long |
float |
float |
FloatHolder |
FloatHolder |
float |
double |
double |
DoubleHolder |
DoubleHolder |
double |
char |
char |
CharHolder |
CharHolder |
char |
wchar |
char |
CharHolder |
CharHolder |
char |
string |
java.lang.String |
StringHolder |
StringHolder |
java.lang.String |
wstring |
java.lang.String |
StringHolder |
StringHolder |
java.lang.String |
boolean |
boolean |
BooleanHolder |
BooleanHolder |
boolean |
octet |
byte |
ByteHolder |
ByteHolder |
byte |
Explanation
in
parameters: Passed as primitive types or Java reference types directly.
out
parameters: Mapped to CORBA-specific Holder
classes (ShortHolder
, IntHolder
, etc.), allowing the method to return values via references.
inout
parameters: Also use Holder
classes, as they require both passing in and modifying values.
- Return type: Corresponds directly to a Java primitive or object type.
Example CORBA IDL to Java Mapping
IDL Definition
interface ExampleInterface {
short addShort(in short a, in short b);
void getFloatValues(out float a, out float b);
void updateString(inout string s);
};
Java Interface (Generated by IDL Compiler)
public interface ExampleInterface extends org.omg.CORBA.Object {
public short addShort(short a, short b); // 'in' params as primitive types, return type as short
public void getFloatValues(FloatHolder a, FloatHolder b); // 'out' params as FloatHolder
public void updateString(StringHolder s); // 'inout' param as StringHolder
}
This table serves as a useful guide for predicting how an IDL compiler translates IDL method signatures into Java method signatures in CORBA applications.