OOPortal
J2EEOnline RationalDB
prev next prev next
Course navigation
Lesson 4 Primitive data types
Objective Describe the mapping of IDL primitive types to Java types.
All complex types are built from a set of primitive types. Before we build up a mapping of more complex types, we need to look at how the primitive types in IDL translate to types in Java.
Primitive types
The conversion of primitive types is summed up in the table below:
IDL Java type
short short
long int
long long long
unsigned short short
unsigned long int
unsigned long long long
float float
double double
char char
wchar char
string java.lang.String
wstring java.lang.String
boolean boolean
octet byte
object org.omg.CORBA.Object
Shorts and longs
An IDL short is defined as a 16-bit value, whereas an IDL long is defined as 32-bit. In Java, a short is defined as 16 bits, int as 32 bits, and long as 64 bits. Therefore an IDL long maps to a Java int and an IDLlong long maps to a Java long. Because Java characters are always Unicode, the IDL types wchar and wstring (wide char and wide string) map directly to Java char and java.lang.String. Even though char and string in IDL use only bytes for character values, for usability it makes sense that char and string map to Java char and java.lang.String as well.
A marshalling exception can occur when converting the Unicode to bytes if the Unicode is something other than then a basic Latin-1 (ISO 8859.1) character set.
Marshalling: Conversion of language-specific data types to values, which can be put onto a byte stream.
In the next lesson, you will learn how to describe the mapping of IDL constants and typedefs in Java.
Course navigation