Java Programming  «Prev  Next»
Lesson 5 Constants and Typedefs in CORBA Java Mapping
Objective Explain how IDL constants and typedefs are mapped into Java classes and interfaces.

Mapping CORBA Constants and Typedefs to Java

Main point: Constants and typedefs in CORBA’s Interface Definition Language (IDL) are simple constructs that enable better readability and type safety. When mapped to Java, they become part of the generated classes and packages that represent IDL modules, preserving names and structure while adapting to Java’s type system.

1. Constants in CORBA IDL

An IDL const defines a fixed value that remains constant throughout program execution. In Java, how that constant is mapped depends on where it is defined:

This mapping ensures that all constants are available in a type-safe and namespace-aware way, preserving both modularity and encapsulation.

2. How the Mapping Works

The process of mapping constants and typedefs follows a clear sequence. Originally shown in four diagrams, this sequence can be summarized as the logical workflow below:

  1. Module Packaging: All IDL elements within a module belong to the same generated Java package. The IDL compiler does not produce client code, so the implementer decides where client classes reside.
  2. Interface Mapping: The IDL interface becomes a Java interface containing all declared operations and constants. It extends org.omg.CORBA.Object.
  3. Constant Classes: Each constant defined at module scope is generated as its own Java class, using the constant’s name as the class name. Its value is stored in a public static final field named value.
  4. Interface-Level Constants: Constants defined inside IDL interfaces are declared as public static final variables directly in the generated Java interface.


Constants defined in interfaces are declared as static variables in the Java interface already generated for the IDL interface
IDL constants and typedefs mapped to Java — each constant becomes a public static final field or, if defined at module scope, its own class with a value field.

3. Typedefs and Their Role in Java

IDL typedefs provide alternate names for existing types. Their purpose is mainly semantic clarity—allowing an IDL to use meaningful type names (like AccountID instead of long)—and limited change management. However, Java does not support true type aliasing, so typedefs in IDL do not create new Java classes. Instead, they map directly to the base type.

Helper and holder classes are still generated for typedefs, allowing developers to work with those names in parameter passing and method calls. This preserves backward compatibility even though Java omits explicit aliases.

4. Pseudo Object Types and ORB Support

CORBA also defines several pseudo object types used internally by the Object Request Broker (ORB). These objects have IDL interfaces but are not true distributed objects. They provide essential runtime support and are typically used as attributes or parameter types in IDL specifications.

The most common pseudo object types include:

CORBA::NamedValue
CORBA::TypeCode

To use these in an IDL specification, the following include directive is required:


#include <orb.idl>
// ...

This ensures the IDL compiler can recognize NamedValue and TypeCode when generating corresponding Java bindings.

5. Summary

Understanding how these constructs translate between IDL and Java is essential for maintaining or refactoring CORBA-based systems. Even though modern distributed systems may favor gRPC or REST, these mappings remain instructive examples of language-agnostic interface design.

Next Lesson

In the next module, you’ll learn how to map IDL methods and attributes to Java, including how to handle remote invocations and manage in, out, and inout parameters.


IDL Java Mapping - Quiz

Click the Quiz link below to take a quiz on IDL-to-Java mapping.
IDL Java Mapping - Quiz

SEMrush Software