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