blob: 86459fc4f4c19b7871ec16f41e4bf11f3202f4a5 [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001." Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
2." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3."
4." This code is free software; you can redistribute it and/or modify it
5." under the terms of the GNU General Public License version 2 only, as
6." published by the Free Software Foundation.
7."
8." This code is distributed in the hope that it will be useful, but WITHOUT
9." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11." version 2 for more details (a copy is included in the LICENSE file that
12." accompanied this code).
13."
14." You should have received a copy of the GNU General Public License version
15." 2 along with this work; if not, write to the Free Software Foundation,
16." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17."
ohair2283b9d2010-05-25 15:58:33 -070018." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19." or visit www.oracle.com if you need additional information or have any
20." questions.
duke6e45e102007-12-01 00:00:00 +000021."
tbell16c34dd2009-05-04 18:28:26 -070022.TH idlj 1 "04 May 2009"
23." Generated from HTML by html2man (author: Eric Armstrong)
duke6e45e102007-12-01 00:00:00 +000024
25.LP
tbell16c34dd2009-05-04 18:28:26 -070026.SH "Name"
duke6e45e102007-12-01 00:00:00 +000027idlj \- The IDL\-to\-Java Compiler
28.LP
29.RS 3
30
31.LP
32\f3idlj\fP generates Java bindings from a given IDL file.
33.RE
34.SH "Synopsis"
35.LP
36
37.LP
38.nf
39\f3
40.fl
41idlj [ \fP\f3options\fP\f3 ] \fP\f4idl\-file\fP\f3
42.fl
43\fP
44.fi
45
46.LP
47.LP
48where \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.
49.LP
50.SH "Description"
51.LP
52
53.LP
tbell16c34dd2009-05-04 18:28:26 -070054The IDL\-to\-Java Compiler generates the Java bindings for a given IDL file.\ For binding details, see the
55.na
56\f2OMG IDL to Java Language Language Mapping Specification\fP @
57.fi
58http://java.sun.com/javase/6/docs/technotes/guides/idl/mapping/jidlMapping.html. Some previous releases of the IDL\-to\-Java compiler were named \f2idltojava\fP.
duke6e45e102007-12-01 00:00:00 +000059.SS
60Emitting Client and Server Bindings
61.LP
62.RS 3
63
64.LP
65To generate Java bindings for an IDL file named My.idl: \f2idlj My.idl\fP
66.LP
67This generates the client\-side bindings and is equivalent to: \f2idlj \fP\f4\-fclient\fP\f2 My.idl\fP
68.LP
69The 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
70.LP
71Server\-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
72.br
73\f2idlj \fP\f4\-fall\fP\f2 My.idl\fP
74.LP
75.LP
76There are two possible server\-side models: the Inheritance Model and the Tie Delegation Model.
77.LP
78.LP
79The 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.
80.LP
81.LP
tbell16c34dd2009-05-04 18:28:26 -070082\f2MyPOA.java\fP is a stream\-based skeleton that extends
83.na
84\f2org.omg.PortableServer.Servant\fP @
85.fi
86http://java.sun.com/javase/6/docs/api/org/omg/PortableServer/Servant.html and implements the \f2InvokeHandler\fP interface and the operations interface associated with the IDL interface the skeleton implements.
duke6e45e102007-12-01 00:00:00 +000087.LP
88.LP
tbell16c34dd2009-05-04 18:28:26 -070089The \f2PortableServer\fP module for the
90.na
91\f2Portable Object Adapter (POA)\fP @
92.fi
93http://java.sun.com/javase/6/docs/technotes/guides/idl/POA.html 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.
duke6e45e102007-12-01 00:00:00 +000094.LP
95.LP
96Another 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:
97.LP
98\f2idlj \fP\f4\-fclient \-fserver\fP\f2 \fP\f4\-oldImplBase\fP\f2 My.idl\fP
99.br
100\f2idlj \fP\f4\-fall\fP\f2 \fP\f4\-oldImplBase\fP\f2 My.idl\fP
101.LP
102Given 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.
103.LP
104The 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:
105.LP
106\f2idlj \fP\f4\-fall\fP\f2 My.idl\fP
107.br
108\f2idlj \fP\f4\-fallTIE\fP\f2 My.idl\fP
109.LP
110For 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:
111.nf
112\f3
113.fl
114 ORB orb = ORB.init(args, System.getProperties());
115.fl
116
117.fl
118 // Get reference to rootpoa & activate the POAManager
119.fl
120 POA rootpoa = (POA)orb.resolve_initial_references("RootPOA");
121.fl
122 rootpoa.the_POAManager().activate();
123.fl
124
125.fl
126 // create servant and register it with the ORB
127.fl
128 MyServant myDelegate = new MyServant();
129.fl
130 myDelegate.setORB(orb);
131.fl
132
133.fl
134 // create a tie, with servant being the delegate.
135.fl
136 MyPOATie tie = new MyPOATie(myDelegate, rootpoa);
137.fl
138
139.fl
140 // obtain the objectRef for the tie
141.fl
142 My ref = tie._this(orb);
143.fl
144\fP
145.fi
146
147.LP
148You 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.
149.LP
150To 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.
151.LP
152\f2idlj \fP\f4\-oldImplBase\fP\f2 \fP\f4\-fall\fP\f2 My.idl\fP
153.br
154\f2idlj \fP\f4\-oldImplBase\fP\f2 \fP\f4\-fallTIE\fP\f2 My.idl\fP
155.LP
156.LP
157For 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:
158.LP
159.nf
160\f3
161.fl
162 ORB orb = ORB.init(args, System.getProperties());
163.fl
164
165.fl
166 // create servant and register it with the ORB
167.fl
168 MyServant myDelegate = new MyServant();
169.fl
170 myDelegate.setORB(orb);
171.fl
172
173.fl
174 // create a tie, with servant being the delegate.
175.fl
176 MyPOATie tie = new MyPOATie(myDelegate);
177.fl
178
179.fl
180 // obtain the objectRef for the tie
181.fl
182 My ref = tie._this(orb);
183.fl
184\fP
185.fi
186
187.LP
188.RE
189.SS
190Specifying Alternate Locations for Emitted Files
191.LP
192.RS 3
193
194.LP
195If you want to direct the emitted files to a directory other than the current directory, invoke the compiler as:
196.RS 3
197
198.LP
199\f2idlj \fP\f4\-td /altdir\fP\f2 My.idl\fP
200.RE
201For the interface \f2My\fP, the bindings will be emitted to \f2/altdir/My.java\fP, etc., instead of \f2./My.java\fP.
202.RE
203.SS
204Specifying Alternate Locations for Include Files
205.LP
206.RS 3
207
208.LP
209If \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
210.LP
211If \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
212.LP
213Since 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
214.LP
tbell16c34dd2009-05-04 18:28:26 -0700215The 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, see the
216.na
217\f2Setting the Classpath\fP @
218.fi
219http://java.sun.com/javase/6/docs/technotes/tools/index.html#general.
duke6e45e102007-12-01 00:00:00 +0000220.RE
221.SS
222Emitting Bindings for Include Files
223.LP
224.RS 3
225
226.LP
227By 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
228.LP
229\f2#include <MyOther.idl>\fP
230.br
231\f2interface My\fP
232.br
233\f2{\fP
234.br
235\f2};\fP
236.br
237\f4MyOther.idl\fP
238.LP
239\f2interface MyOther\fP
240.br
241\f2{\fP
242.br
243\f2};\fP\
244.LP
245The following command will only generate the java bindings for \f2My\fP: \f2idlj My.idl\fP
246.LP
247To 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
248.LP
249There 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
250.LP
251\f2#include <MyOther.idl>\fP
252.br
253\f2interface My\fP
254.br
255\f2{\fP
256.br
257\f2\ #include <Embedded.idl>\fP
258.br
259\f2};\ \fP \f4MyOther.idl\fP
260.LP
261\f2interface MyOther\fP
262.br
263\f2{\fP
264.br
265\f2};\ \fP \f4Embedded.idl\fP
266.LP
267\f2enum E {one, two, three};\fP\
268.LP
269Running the following command: \f2idlj My.idl\fP
270.LP
271will generate the following list of Java files: \f2./MyHolder.java\fP
272.br
273\f2./MyHelper.java\fP
274.br
275\f2./_MyStub.java\fP
276.br
277\f2./MyPackage\fP
278.br
279\f2./MyPackage/EHolder.java\fP
280.br
281\f2./MyPackage/EHelper.java\fP
282.br
283\f2./MyPackage/E.java\fP
284.br
285\f2./My.java\fP
286.LP
287Notice 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).
288.LP
289If the \f2\-emitAll\fP flag had been used in the previous example, then all types in all included files would be emitted.
290.LP
291.RE
292.SS
293Inserting Package Prefixes
294.LP
295.RS 3
296
297.LP
298Suppose that you work for a company named ABC that has constructed the following IDL file:
299.br
300\f4Widgets.idl\fP
301.LP
302\f2module Widgets\fP
303.br
304\f2{\fP
305.br
306\f2\ interface W1 {...};\fP
307.br
308\f2\ interface W2 {...};\fP
309.br
310\f2};\fP\
311.LP
312Running 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
313.LP
314If 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.
315.LP
316If 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:
317.LP
318\f2PkgPrefix.<type>=<prefix>\fP
319.LP
320So the line for the above example would be: \f2PkgPrefix.Widgets=com.abc\fP
321.LP
322.LP
323The use of this option does not affect the Repository ID.
324.LP
325.RE
326.SS
327Defining Symbols Before Compilation
328.LP
329.RS 3
330
331.LP
332You 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
333.LP
334is the equivalent of putting the line \f2#define MYDEF\fP inside \f2My.idl\fP.
335.RE
336.SS
337Preserving Pre\-Existing Bindings
338.LP
339.RS 3
340
341.LP
342If 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
343.LP
344emit all client\-side bindings that do not already exist.
345.RE
346.SS
347Viewing Progress of Compilation
348.LP
349.RS 3
350
351.LP
352The 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
353.LP
354By default the compiler does not operate in verbose mode.
355.RE
356.SS
357Displaying Version Information
358.LP
359.RS 3
360
361.LP
362.LP
363To display the build version of the IDL\-to\-Java compiler, specify the \f2\-version\fP option on the command\-line:
364.LP
365.LP
366\f2idlj \-version\fP
367.LP
368.LP
369Version information also appears within the bindings generated by the compiler. Any additional options appearing on the command\-line are ignored.
370.LP
371.RE
372.SH "Options"
373.LP
374
375.LP
376.RS 3
377.TP 3
378\-d symbol
379This is equivalent to the following line in an IDL file:
380.RS 3
381
382.LP
383.nf
384\f3
385.fl
386#define \fP\f4symbol\fP\f3
387.fl
388\fP
389.fi
390.RE
391.TP 3
392\-emitAll
393Emit all types, including those found in \f2#include\fP files.
394.TP 3
395\-fside
396Defines 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.
397.TP 3
398\-i include\-path
399By default, the current directory is scanned for included files. This option adds another directory.
400.TP 3
401\-keep
402If a file to be generated already exists, do not overwrite it. By default it is overwritten.
403.TP 3
404\-noWarn
405Suppresses warning messages.
406.TP 3
407\-oldImplBase
408Generates 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.
409.TP 3
410\-pkgPrefix type prefix
411Wherever \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.
412.TP 3
413\-pkgTranslate type package
414Whenever 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.
415.LP
416If more than one translation matches an identifier, the longest match is chosen. For example, if the arguments include:
417.nf
418\f3
419.fl
420 \-pkgTranslate foo bar \-pkgTranslate foo.baz buzz.fizz
421.fl
422\fP
423.fi
424.LP
425The following translations would occur:
426.nf
427\f3
428.fl
429foo => bar
430.fl
431foo.boo => bar.boo
432.fl
433foo.baz => buzz.fizz
434.fl
435foo.baz.bar => buzz.fizz.bar
436.fl
437\fP
438.fi
439.LP
440The following package names cannot be translated:
441.RS 3
442.TP 2
443o
444\f2org\fP
445.TP 2
446o
447\f2org.omg\fP or any subpackages of \f2org.omg\fP
448.RE
449.LP
450Any 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.
451.TP 3
452\-skeletonName xxx%yyy
453Use \f2xxx%yyy\fP as the pattern for naming the skeleton. The defaults are:
454.RS 3
455.TP 2
456o
457%POA for the \f2POA\fP base class (\f2\-fserver\fP or \f2\-fall\fP)
458.TP 2
459o
460_%ImplBase for the \f2oldImplBase\fP class (\f2\-oldImplBase\fP and (\f2\-fserver\fP or \f2\-fall\fP))
461.RE
462.TP 3
463\-td dir
464Use \f2dir\fP for the output directory instead of the current directory.
465.TP 3
466\-tieName xxx%yyy
467Name the tie according to the pattern. The defaults are:
468.RS 3
469.TP 2
470o
471%POATie for the \f2POA\fP tie base class (\f2\-fserverTie\fP or \f2\-fallTie\fP)
472.TP 2
473o
474%_Tie for the \f2oldImplBase\fP tie class (\f2\-oldImplBase\fP and (\f2\-fserverTie\fP or \f2\-fallTie\fP))
475.RE
476.TP 3
477\-nowarn, \-verbose
478Verbose mode.
479.TP 3
480\-version
481Display version information and terminate.
482.RE
483
484.LP
485See the Description section for more option information.
486.SH "Restrictions:"
487.LP
488
489.LP
490.RS 3
491.TP 2
492o
493Escaped 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).
494.TP 2
495o
496The \f2fixed\fP IDL type is not supported.
497.RE
498
499.LP
500.SH "Known Problems:"
501.LP
502
503.LP
504.RS 3
505.TP 2
506o
507No 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.
508.RE
509
510.LP
511
512.LP
513