blob: 6e19b3fdf7c236f3d9ff1eadd80b50e9b01b77b0 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001.'" t
2." Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
3." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4."
5." This code is free software; you can redistribute it and/or modify it
6." under the terms of the GNU General Public License version 2 only, as
7." published by the Free Software Foundation.
8."
9." This code is distributed in the hope that it will be useful, but WITHOUT
10." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12." version 2 for more details (a copy is included in the LICENSE file that
13." accompanied this code).
14."
15." You should have received a copy of the GNU General Public License version
16." 2 along with this work; if not, write to the Free Software Foundation,
17." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18."
19." Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20." CA 95054 USA or visit www.sun.com if you need additional information or
21." have any questions.
22." `
23.TH idlj 1 "07 Aug 2006"
24." Generated by html2man
25
26.LP
27.SH NAME
28idlj \- The IDL\-to\-Java Compiler
29.LP
30.RS 3
31
32.LP
33\f3idlj\fP generates Java bindings from a given IDL file.
34.RE
35.SH "Synopsis"
36.LP
37
38.LP
39.nf
40\f3
41.fl
42idlj [ \fP\f3options\fP\f3 ] \fP\f4idl\-file\fP\f3
43.fl
44\fP
45.fi
46
47.LP
48.LP
49where \f2idl\-file\fP is the name of a file containing Interface Definition Language (IDL) definitions. \f2Options\fP may appear in any order, but must precede the \f2idl\-file\fP.
50.LP
51.SH "Description"
52.LP
53
54.LP
55The IDL\-to\-Java Compiler generates the Java bindings for a given IDL file.\ For binding details, see the OMG IDL to Java Language Language Mapping Specification. Some previous releases of the IDL\-to\-Java compiler were named \f2idltojava\fP.
56.SS
57Emitting Client and Server Bindings
58.LP
59.RS 3
60
61.LP
62To generate Java bindings for an IDL file named My.idl: \f2idlj My.idl\fP
63.LP
64This generates the client\-side bindings and is equivalent to: \f2idlj \fP\f4\-fclient\fP\f2 My.idl\fP
65.LP
66The client\-side bindings do not include the server\-side skeleton. If you want to generate the server\-side bindings for the interfaces: \f2idlj \fP\f4\-fserver\fP\f2 My.idl\fP
67.LP
68Server\-side bindings include the client\-side bindings plus the skeleton, all of which are \f2POA\fP (that is, Inheritance Model) classes. If you want to generate both client and server\-side bindings, use one of the following (equivalent) commands: \f2idlj \fP\f4\-fclient \-fserver\fP\f2 My.idl\fP
69.br
70\f2idlj \fP\f4\-fall\fP\f2 My.idl\fP
71.LP
72.LP
73There are two possible server\-side models: the Inheritance Model and the Tie Delegation Model.
74.LP
75.LP
76The default server\-side model is the \f2Portable Servant Inheritance Model\fP. Given an interface \f2My\fP defined in \f2My.idl\fP, the file \f2MyPOA.java\fP is generated. You must provide the implementation for \f2My\fP and it must inherit from \f2MyPOA\fP.
77.LP
78.LP
79\f2MyPOA.java\fP is a stream\-based skeleton that extends \f2org.omg.PortableServer.Servant\fP and implements the \f2InvokeHandler\fP interface and the operations interface associated with the IDL interface the skeleton implements.
80.LP
81.LP
82The \f2PortableServer\fP module for the Portable Object Adapter (POA) defines the native \f2Servant\fP type. In the Java programming language, the \f2Servant\fP type is mapped to the Java \f2org.omg.PortableServer.Servant\fP class. It serves as the base class for all POA servant implementations and provides a number of methods that may be invoked by the application programmer, as well as methods which are invoked by the POA itself and may be overridden by the user to control aspects of servant behavior.
83.LP
84.LP
85Another option for the Inheritance Model is to use the \f2\-oldImplBase\fP flag in order to generate server\-side bindings that are compatible with versions of the Java programming language prior to J2SE 1.4. Note that using the \f2\-oldImplBase\fP flag is non\-standard: these APIs are being deprecated. You would use this flag ONLY for compatibility with existing servers written in J2SE 1.3. In that case, you would need to modify an existing MAKEFILE to add the \f2\-oldImplBase\fP flag to the \f2idlj\fP compiler, otherwise POA\-based server\-side mappings will be generated. To generate server\-side bindings that are backwards compatible:
86.LP
87\f2idlj \fP\f4\-fclient \-fserver\fP\f2 \fP\f4\-oldImplBase\fP\f2 My.idl\fP
88.br
89\f2idlj \fP\f4\-fall\fP\f2 \fP\f4\-oldImplBase\fP\f2 My.idl\fP
90.LP
91Given an interface \f2My\fP defined in \f2My.idl\fP, the file \f2_MyImplBase.java\fP is generated. You must provide the implementation for \f2My\fP and it must inherit from \f2_MyImplBase\fP.
92.LP
93The other server\-side model is called the Tie Model. This is a delegation model. Because it is not possible to generate ties and skeletons at the same time, they must be generated separately. The following commands generate the bindings for the Tie Model:
94.LP
95\f2idlj \fP\f4\-fall\fP\f2 My.idl\fP
96.br
97\f2idlj \fP\f4\-fallTIE\fP\f2 My.idl\fP
98.LP
99For the interface \f2My\fP, the second command generates \f2MyPOATie.java\fP. The constructor to \f2MyPOATie\fP takes a \f2delegate\fP. In this example, using the default POA model, the constructor also needs a \f2poa\fP. You must provide the implementation for \f2delegate\fP, but it does not have to inherit from any other class, only the interface \f2MyOperations\fP. But to use it with the ORB, you must wrap your implementation within \f2MyPOATie\fP. For instance:
100.nf
101\f3
102.fl
103 ORB orb = ORB.init(args, System.getProperties());
104.fl
105
106.fl
107 // Get reference to rootpoa & activate the POAManager
108.fl
109 POA rootpoa = (POA)orb.resolve_initial_references("RootPOA");
110.fl
111 rootpoa.the_POAManager().activate();
112.fl
113
114.fl
115 // create servant and register it with the ORB
116.fl
117 MyServant myDelegate = new MyServant();
118.fl
119 myDelegate.setORB(orb);
120.fl
121
122.fl
123 // create a tie, with servant being the delegate.
124.fl
125 MyPOATie tie = new MyPOATie(myDelegate, rootpoa);
126.fl
127
128.fl
129 // obtain the objectRef for the tie
130.fl
131 My ref = tie._this(orb);
132.fl
133\fP
134.fi
135
136.LP
137You might want to use the Tie model instead of the typical Inheritance model if your implementation must inherit from some other implementation. Java allows any number of interface inheritance, but there is only one slot for class inheritance. If you use the inheritance model, that slot is used up . By using the Tie Model, that slot is freed up for your own use. The drawback is that it introduces a level of indirection: one extra method call occurs when invoking a method.
138.LP
139To generate server\-side, Tie model bindings that are compatible with versions of the IDL to Java language mapping in versions prior to J2SE 1.4.
140.LP
141\f2idlj \fP\f4\-oldImplBase\fP\f2 \fP\f4\-fall\fP\f2 My.idl\fP
142.br
143\f2idlj \fP\f4\-oldImplBase\fP\f2 \fP\f4\-fallTIE\fP\f2 My.idl\fP
144.LP
145.LP
146For the interface \f2My\fP, this will generate \f2My_Tie.java\fP. The constructor to \f2My_Tie\fP takes a \f2impl\fP. You must provide the implementation for \f2impl\fP, but it does not have to inherit from any other class, only the interface \f2HelloOperations\fP. But to use it with the ORB, you must wrap your implementation within \f2My_Tie\fP. For instance:
147.LP
148.nf
149\f3
150.fl
151 ORB orb = ORB.init(args, System.getProperties());
152.fl
153
154.fl
155 // create servant and register it with the ORB
156.fl
157 MyServant myDelegate = new MyServant();
158.fl
159 myDelegate.setORB(orb);
160.fl
161
162.fl
163 // create a tie, with servant being the delegate.
164.fl
165 MyPOATie tie = new MyPOATie(myDelegate);
166.fl
167
168.fl
169 // obtain the objectRef for the tie
170.fl
171 My ref = tie._this(orb);
172.fl
173\fP
174.fi
175
176.LP
177.RE
178.SS
179Specifying Alternate Locations for Emitted Files
180.LP
181.RS 3
182
183.LP
184If you want to direct the emitted files to a directory other than the current directory, invoke the compiler as:
185.RS 3
186
187.LP
188\f2idlj \fP\f4\-td /altdir\fP\f2 My.idl\fP
189.RE
190For the interface \f2My\fP, the bindings will be emitted to \f2/altdir/My.java\fP, etc., instead of \f2./My.java\fP.
191.RE
192.SS
193Specifying Alternate Locations for Include Files
194.LP
195.RS 3
196
197.LP
198If \f2My.idl\fP included another idl file, \f2MyOther.idl\fP, the compiler assumes that \f2MyOther.idl\fP resides in the local directory. If it resides in \f2/includes\fP, for example, then you would invoke the compiler with the following command: \f2idlj \fP\f4\-i /includes\fP\f2 My.idl\fP
199.LP
200If \f2My.idl\fP also included \f2Another.idl\fP that resided in \f2/moreIncludes\fP, for example, then you would invoke the compiler with the following command: \f2idlj \fP\f4\-i /includes \-i /moreIncludes\fP\f2 My.idl\fP
201.LP
202Since this form of include can become irritatingly long, another means of indicating to the compiler where to search for included files is provided. This technique is similar to the idea of an environment variable. Create a file named \f2idl.config\fP in a directory that is listed in your CLASSPATH. Inside of \f2idl.config\fP, provide a line with the following form: \f2includes=/includes;/moreIncludes\fP
203.LP
204The compiler will find this file and read in the includes list. Note that in this example the separator character between the two directories is a semicolon (;). This separator character is platform dependent. On the Windows platform, use a semicolon, on the Unix platform, use a colon, etc. For more information on \f2includes\fP, read the CLASSPATH\ (Solaris) or CLASSPATH\ (Windows) documentation.
205.RE
206.SS
207Emitting Bindings for Include Files
208.LP
209.RS 3
210
211.LP
212By default, only those interfaces, structs, etc, that are defined in the idl file on the command line have Java bindings generated for them. The types defined in included files are not generated. For example, assume the following two idl files: \f4My.idl\fP
213.LP
214\f2#include <MyOther.idl>\fP
215.br
216\f2interface My\fP
217.br
218\f2{\fP
219.br
220\f2};\fP
221.br
222\f4MyOther.idl\fP
223.LP
224\f2interface MyOther\fP
225.br
226\f2{\fP
227.br
228\f2};\fP\
229.LP
230The following command will only generate the java bindings for \f2My\fP: \f2idlj My.idl\fP
231.LP
232To generate all of the types in \f2My.idl\fP and all of the types in the files that \f2My.idl\fP includes (in this example, \f2MyOther.idl\fP), use the following command: \f2idlj \fP\f4\-emitAll\fP\f2 My.idl\fP
233.LP
234There is a caveat to the default rule. \f2#include\fP statements which appear at global scope are treated as described. These \f2#include\fP statements can be thought of as import statements. \f2#include\fP statements which appear within some enclosing scope are treated as true \f2#include\fP statements, meaning that the code within the included file is treated as if it appeared in the original file and, therefore, Java bindings are emitted for it. Here is an example: \f4My.idl\fP
235.LP
236\f2#include <MyOther.idl>\fP
237.br
238\f2interface My\fP
239.br
240\f2{\fP
241.br
242\f2\ #include <Embedded.idl>\fP
243.br
244\f2};\ \fP \f4MyOther.idl\fP
245.LP
246\f2interface MyOther\fP
247.br
248\f2{\fP
249.br
250\f2};\ \fP \f4Embedded.idl\fP
251.LP
252\f2enum E {one, two, three};\fP\
253.LP
254Running the following command: \f2idlj My.idl\fP
255.LP
256will generate the following list of Java files: \f2./MyHolder.java\fP
257.br
258\f2./MyHelper.java\fP
259.br
260\f2./_MyStub.java\fP
261.br
262\f2./MyPackage\fP
263.br
264\f2./MyPackage/EHolder.java\fP
265.br
266\f2./MyPackage/EHelper.java\fP
267.br
268\f2./MyPackage/E.java\fP
269.br
270\f2./My.java\fP
271.LP
272Notice that \f2MyOther.java\fP was not generated because it is defined in an import\-like \f2#include\fP. But \f2E.java\fP \f2was\fP generated because it was defined in a true \f2#include\fP. Also notice that since \f2Embedded.idl\fP was included within the scope of the interface \f2My\fP, it appears within the scope of \f2My\fP (that is,in \f2MyPackage\fP).
273.LP
274If the \f2\-emitAll\fP flag had been used in the previous example, then all types in all included files would be emitted.
275.LP
276.RE
277.SS
278Inserting Package Prefixes
279.LP
280.RS 3
281
282.LP
283Suppose that you work for a company named ABC that has constructed the following IDL file:
284.br
285\f4Widgets.idl\fP
286.LP
287\f2module Widgets\fP
288.br
289\f2{\fP
290.br
291\f2\ interface W1 {...};\fP
292.br
293\f2\ interface W2 {...};\fP
294.br
295\f2};\fP\
296.LP
297Running this file through the IDL\-to\-Java compiler will place the Java bindings for \f2W1\fP and \f2W2\fP within the package \f2Widgets\fP. But there is an industry convention that states that a company's packages should reside within a package named \f2com.<company name>\fP. The \f2Widgets\fP package is not good enough. To follow convention, it should be \f2com.abc.Widgets\fP. To place this package prefix onto the \f2Widgets\fP module, execute the following: \f2idlj \fP\f4\-pkgPrefix Widgets com.abc\fP\f2 Widgets.idl\fP
298.LP
299If you have an IDL file which includes \f2Widgets.idl\fP, the \f2\-pkgPrefix\fP flag must appear in that command also. If it does not, then your IDL file will be looking for a \f2Widgets\fP package rather than a \f2com.abc.Widgets\fP package.
300.LP
301If you have a number of these packages that require prefixes, it might be easier to place them into the \f2idl.config\fP file described above. Each package prefix line should be of the form:
302.LP
303\f2PkgPrefix.<type>=<prefix>\fP
304.LP
305So the line for the above example would be: \f2PkgPrefix.Widgets=com.abc\fP
306.LP
307.LP
308The use of this option does not affect the Repository ID.
309.LP
310.RE
311.SS
312Defining Symbols Before Compilation
313.LP
314.RS 3
315
316.LP
317You may need to define a symbol for compilation that is not defined within the IDL file, perhaps to include debugging code in the bindings. The command \f2idlj \fP\f4\-d\fP\f2 MYDEF My.idl\fP
318.LP
319is the equivalent of putting the line \f2#define MYDEF\fP inside \f2My.idl\fP.
320.RE
321.SS
322Preserving Pre\-Existing Bindings
323.LP
324.RS 3
325
326.LP
327If the Java binding files already exist, the \f2\-keep\fP flag will keep the compiler from overwriting them. The default is to generate all files without considering if they already exist. If you've customized those files (which you should not do unless you are very comfortable with their contents), then the \f2\-keep\fP option is very useful. The command \f2idlj \fP\f4\-keep\fP\f2 My.idl\fP
328.LP
329emit all client\-side bindings that do not already exist.
330.RE
331.SS
332Viewing Progress of Compilation
333.LP
334.RS 3
335
336.LP
337The IDL\-to\-Java compiler will generate status messages as it progresses through its phases of execution. Use the \f2\-v\fP option to activate this "verbose" mode: \f2idlj \fP\f4\-v\fP\f2 My.idl\fP
338.LP
339By default the compiler does not operate in verbose mode.
340.RE
341.SS
342Displaying Version Information
343.LP
344.RS 3
345
346.LP
347.LP
348To display the build version of the IDL\-to\-Java compiler, specify the \f2\-version\fP option on the command\-line:
349.LP
350.LP
351\f2idlj \-version\fP
352.LP
353.LP
354Version information also appears within the bindings generated by the compiler. Any additional options appearing on the command\-line are ignored.
355.LP
356.RE
357.SH "Options"
358.LP
359
360.LP
361.RS 3
362.TP 3
363\-d symbol
364This is equivalent to the following line in an IDL file:
365.RS 3
366
367.LP
368.nf
369\f3
370.fl
371#define \fP\f4symbol\fP\f3
372.fl
373\fP
374.fi
375.RE
376.TP 3
377\-emitAll
378Emit all types, including those found in \f2#include\fP files.
379.TP 3
380\-fside
381Defines what bindings to emit. \f2side\fP is one of \f2client\fP, \f2server\fP, \f2serverTIE\fP, \f2all\fP, or \f2allTIE\fP. The \f2\-fserverTIE\fP and \f2\-fallTIE\fP options cause delegate model skeletons to be emitted. Assumes \f2\-fclient\fP if the flag is not specified.
382.TP 3
383\-i include\-path
384By default, the current directory is scanned for included files. This option adds another directory.
385.TP 3
386\-keep
387If a file to be generated already exists, do not overwrite it. By default it is overwritten.
388.TP 3
389\-noWarn
390Suppresses warning messages.
391.TP 3
392\-oldImplBase
393Generates skeletons compatible with pre\-1.4 JDK ORBs. By default, the POA Inheritance Model server\-side bindings are generated. This option provides backward\-compatibility with older versions of the Java programming language by generating server\-side bindings that are \f2ImplBase\fP Inheritance Model classes.
394.TP 3
395\-pkgPrefix type prefix
396Wherever \f2type\fP is encountered at file scope, prefix the generated Java package name with \f2prefix\fP for all files generated for that type. The \f2type\fP is the simple name of either a top\-level module, or an IDL type defined outside of any module.
397.TP 3
398\-pkgTranslate type package
399Whenever the module name \f2type\fP is encountered in an identifier, replace it in the identifier with \f2package\fP for all files in the generated Java package. Note that \f2pkgPrefix\fP changes are made first. \f2type\fP is the simple name of either a top\-level module, or an IDL type defined outside of any module, and must match the full package name exactly.
400.LP
401If more than one translation matches an identifier, the longest match is chosen. For example, if the arguments include:
402.nf
403\f3
404.fl
405 \-pkgTranslate foo bar \-pkgTranslate foo.baz buzz.fizz
406.fl
407\fP
408.fi
409.LP
410The following translations would occur:
411.nf
412\f3
413.fl
414foo => bar
415.fl
416foo.boo => bar.boo
417.fl
418foo.baz => buzz.fizz
419.fl
420foo.baz.bar => buzz.fizz.bar
421.fl
422\fP
423.fi
424.LP
425The following package names cannot be translated:
426.RS 3
427.TP 2
428o
429\f2org\fP
430.TP 2
431o
432\f2org.omg\fP or any subpackages of \f2org.omg\fP
433.RE
434.LP
435Any attempt to translate these packages will result in uncompilable code, and the use of these packages as the first argument after \f2\-pkgTranslate\fP will be treated as an error.
436.TP 3
437\-skeletonName xxx%yyy
438Use \f2xxx%yyy\fP as the pattern for naming the skeleton. The defaults are:
439.RS 3
440.TP 2
441o
442%POA for the \f2POA\fP base class (\f2\-fserver\fP or \f2\-fall\fP)
443.TP 2
444o
445_%ImplBase for the \f2oldImplBase\fP class (\f2\-oldImplBase\fP and (\f2\-fserver\fP or \f2\-fall\fP))
446.RE
447.TP 3
448\-td dir
449Use \f2dir\fP for the output directory instead of the current directory.
450.TP 3
451\-tieName xxx%yyy
452Name the tie according to the pattern. The defaults are:
453.RS 3
454.TP 2
455o
456%POATie for the \f2POA\fP tie base class (\f2\-fserverTie\fP or \f2\-fallTie\fP)
457.TP 2
458o
459%_Tie for the \f2oldImplBase\fP tie class (\f2\-oldImplBase\fP and (\f2\-fserverTie\fP or \f2\-fallTie\fP))
460.RE
461.TP 3
462\-nowarn, \-verbose
463Verbose mode.
464.TP 3
465\-version
466Display version information and terminate.
467.RE
468
469.LP
470See the Description section for more option information.
471.SH "Restrictions:"
472.LP
473
474.LP
475.RS 3
476.TP 2
477o
478Escaped identifiers in the global scope may not have the same spelling as IDL primitive types, \f2Object\fP, or \f2ValueBase\fP. This is because the symbol table is pre\-loaded with these identifiers; allowing them to be redefined would overwrite their original definitions. (Possible permanent restriction).
479.TP 2
480o
481The \f2fixed\fP IDL type is not supported.
482.RE
483
484.LP
485.SH "Known Problems:"
486.LP
487
488.LP
489.RS 3
490.TP 2
491o
492No import generated for global identifiers. If you invoke on an unexported local impl, you do get an exception, but it seems to be due to a \f2NullPointerException\fP in the \f2ServerDelegate\fP DSI code.
493.RE
494
495.LP
496
497.LP
498