站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档

Java IDL: Mapping IDL to Java - JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档

Mapping IDL to Java


The tool idltojava, downloadable from the IDL Compiler web site, reads an OMG IDL interface and translates it, or maps it, to a Java interface. idltojava also creates stub, skeleton, helper, holder, and other files as necessary. These .java files are generated from the IDL file according to the mapping specified in the OMG document IDL/Java Language Mapping. We have included four chapters of that document here for your convenience. (You can see the whole document at IDL Java Mapping 1.0). The four chapters included here give the details about mapping OMG IDL to Java. For just a basic summary of mapping IDL to Java, see IDL to Java Overview below.

Chapters from the OMG specification IDL/Java Language Mapping:


Note: Since only chapters 5 through 8 are included here, any links to other chapters in the full mapping specification will not work.

IDL to Java Overview

CORBA objects are defined in OMG IDL (Object Management Group Interface Definition Language). Before they can be used by a Java developer, their interfaces must be mapped to Java classes and interfaces. Java IDL includes a tool, idltojava, that performs this mapping automatically.

This overview shows the correspondence between OMG IDL constructs and Java constructs. Note that OMG IDL, as its name implies, defines interfaces. Like Java interfaces, IDL interfaces contain no implementations for their operations (methods in Java). In other words, IDL interfaces define only the signature for an operation (the name of the operation, the datatype of its return value, the datatypes of the parameters that it takes, and any exceptions that it raises). The implementations for these operations need to be supplied in Java classes written by a Java programmer.

The following table lists the main constructs of IDL and the corresponding constructs in Java.

IDL Construct

Java Construct

module

package

interface

interface, helper class, holder class

constant

public static final

boolean

boolean

char, wchar

char

octet

byte

string, wstring

java.lang.String

short, unsigned short

short

long, unsigned long

int

long long, unsigned long long

long

float

float

double

double

enum, struct, union

class

sequence, array

array

exception

class

readonly attribute

method for accessing value of attrubite

readwrite attribute

methods for accessing and setting value of attribute

operation

method


Note: When a CORBA operation takes a type that corresponds to a Java object type (a String, for example), it is illegal to pass a Java null as the parameter value. Instead, pass an empty version of the designated object type (for example, an empty String or an empty array). A Java null can be passed as a parameter only when the type of the parameter is a CORBA object reference, in which case the null is interpreted as a nil CORBA object reference.

Home


Copyright © 1995-98 Sun Microsystems, Inc. All Rights Reserved.