Java Programming  «Prev  Next»
Lesson 4 Primitive data types
Objective Describe the mapping of IDL primitive types to Java types.

IDL Primitive Data 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.

Appearance of the Propagation Context in Messages

The appearance of the PropagationContext in messages is defined by the CORBA interoperability specification (see the General Inter-ORB Protocol chapter of the Common Object Request Broker: Architecture and Specification). The Transaction Service passes the PropagationContext to the ORB via the TSPortability interface.
  1. When exporting a transaction, the ORB sets the PropagationContext into the ServiceContext::context_data field and marshals the PropagationContext as defined by the GIOP message format and marshalling rules.
  2. When importing a transaction, the ORB demarshalls the ServiceContext::context_data according to the GIOP formatting rules and extracts the PropagationContext to be presented to the Transaction Service.

A marshalling[1] 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.
In the next lesson, you will learn how to describe the mapping of IDL constants and typedefs in Java.

[1]Marshalling: Conversion of language-specific data types to values, which can be put onto a byte stream.