home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book Home Java Enterprise in a Nutshell Search this book

10.2. Identifiers

Identifiers name various IDL constructs, like modules, interfaces, and constants. In IDL, an identifier has to follow these rules:

  • It contains alphanumeric characters from the ISO Latin-1[2] character set (e.g., a-z, A-Z, 0-9, plus various characters with accents, graves, tildes, etc.), and the underscore character ( _ ).

    [2] ISO Latin-1 refers to the standard ISO 8859-1. You can find a listing of the character set in the HTML 3.2 standard, at http://www.w3.org/TR/REC-html32.html.

  • It can be of any length, and all characters in an identifier are significant.

  • The first character must be an alphabetic character.

  • Identifiers are case-insensitive, in the sense that two identifiers that differ only by case are considered a name collision and cause an IDL compiler error. This rule stems from the fact that IDL needs to be mappable into many implementation languages, some of which are case-insensitive.

  • Identifiers must be spelled and capitalized consistently throughout an IDL file.

  • All IDL identifiers share the same namespace, so interfaces, modules, user-defined types, etc. within the same scope must have unique identifiers. An interface named List and a module named List within the same scope cause a name collision and an IDL compiler error. See Section 10.6, "Naming Scopes" for more details.

10.2.1. Mapping Identifiers to Java

An IDL-to-Java compiler attempts to map all IDL identifiers unchanged into equivalent Java identifiers.

An exception is the case where a mapped identifier conflicts with an identifier created automatically by the IDL compiler. IDL interfaces, for example, when they are mapped to Java, have two additional Java interfaces created for them, named with the original interface name, with Helper and Holder appended (see Chapter 4, "Java IDL" for details on the purpose of these generated interfaces). So, an interface named List is mapped into a Java interface named List, and also causes the creation of Java interfaces named ListHelper and ListHolder. If there is another identifier in the IDL file you've named ListHelper or ListHolder, its mapped Java identifier has an underscore prepended to it (e.g., _ListHelper, _ListHolder) to avoid a conflict with the generated interface names. In general, identifiers automatically generated by the IDL compiler have precedence over other identifiers declared explicitly in the IDL file.

The other exception to the general rule of directly mapping IDL identifiers to Java identifiers is with a mapping that conflicts with a Java keyword. In this case, the mapped Java identifier has an underscore prepended to it. If, for example, you declared a constant named package (not a reserved keyword in IDL), it is mapped to a Java variable named _package.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.