]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/java/gcj.texi
gcj.texi (Code Generation): Document -fbootstrap-classes.
[thirdparty/gcc.git] / gcc / java / gcj.texi
1 \input texinfo @c -*-texinfo-*-
2 @setfilename gcj.info
3 @settitle Guide to GNU gcj
4
5 @include gcc-common.texi
6
7 @c Note: When reading this manual you'll find lots of strange
8 @c circumlocutions like ``compiler for the Java language''.
9 @c This is necessary due to Sun's restrictions on the use of
10 @c the word ``Java'.
11
12 @c When this manual is copyrighted.
13 @set copyrights-gcj 2001, 2002, 2003, 2004, 2005
14
15 @c Versions
16 @set which-gcj GCC-@value{version-GCC}
17
18 @copying
19 @c man begin COPYRIGHT
20 Copyright @copyright{} @value{copyrights-gcj} Free Software Foundation, Inc.
21
22 Permission is granted to copy, distribute and/or modify this document
23 under the terms of the GNU Free Documentation License, Version 1.2 or
24 any later version published by the Free Software Foundation; with the
25 Invariant Sections being ``GNU General Public License'', the Front-Cover
26 texts being (a) (see below), and with the Back-Cover Texts being (b)
27 (see below). A copy of the license is included in the
28 @c man end
29 section entitled
30 ``GNU Free Documentation License''.
31 @ignore
32 @c man begin COPYRIGHT
33 man page gfdl(7).
34 @c man end
35 @end ignore
36
37 @c man begin COPYRIGHT
38
39 (a) The FSF's Front-Cover Text is:
40
41 A GNU Manual
42
43 (b) The FSF's Back-Cover Text is:
44
45 You have freedom to copy and modify this GNU Manual, like GNU
46 software. Copies published by the Free Software Foundation raise
47 funds for GNU development.
48 @c man end
49 @end copying
50
51 @ifinfo
52 @format
53 @dircategory Programming
54 @direntry
55 * Gcj: (gcj). Ahead-of-time compiler for the Java language
56 @end direntry
57
58 @dircategory Individual utilities
59 @direntry
60 * gcjh: (gcj)Invoking gcjh.
61 Generate header files from Java class files
62 * gjnih: (gcj)Invoking gjnih.
63 Generate JNI header files from Java class files
64 * jv-scan: (gcj)Invoking jv-scan.
65 Print information about Java source files
66 * jcf-dump: (gcj)Invoking jcf-dump.
67 Print information about Java class files
68 * gij: (gcj)Invoking gij. GNU interpreter for Java bytecode
69 * gcj-dbtool: (gcj)Invoking gcj-dbtool.
70 Tool for manipulating class file databases.
71 * jv-convert: (gcj)Invoking jv-convert.
72 Convert file from one encoding to another
73 * grmic: (gcj)Invoking grmic.
74 Generate stubs for Remote Method Invocation.
75 * grmiregistry: (gcj)Invoking grmiregistry.
76 The remote object registry.
77 @end direntry
78 @end format
79
80 @insertcopying
81 @end ifinfo
82
83 @titlepage
84 @title GNU gcj
85 @author Tom Tromey
86
87 @page
88 @vskip 0pt plus 1filll
89 For the @value{which-gcj} Version*
90 @sp 1
91 Published by the Free Software Foundation @*
92 59 Temple Place - Suite 330@*
93 Boston, MA 02111-1307, USA@*
94 @sp 1
95 @insertcopying
96 @end titlepage
97 @contents
98 @page
99
100
101 @node Top
102 @top Introduction
103
104 This manual describes how to use @command{gcj}, the GNU compiler for the
105 Java programming language. @command{gcj} can generate both @file{.class}
106 files and object files, and it can read both Java source code and
107 @file{.class} files.
108
109 @menu
110 * Copying:: The GNU General Public License
111 * GNU Free Documentation License::
112 How you can share and copy this manual
113 * Invoking gcj:: Compiler options supported by @command{gcj}
114 * Compatibility:: Compatibility between gcj and other tools for Java
115 * Invoking gcjh:: Generate header files from class files
116 * Invoking gjnih:: Generate JNI header files from class files
117 * Invoking jv-scan:: Print information about source files
118 * Invoking jcf-dump:: Print information about class files
119 * Invoking gij:: Interpreting Java bytecodes
120 * Invoking gcj-dbtool:: Tool for manipulating class file databases.
121 * Invoking jv-convert:: Converting from one encoding to another
122 * Invoking grmic:: Generate stubs for Remote Method Invocation.
123 * Invoking grmiregistry:: The remote object registry.
124 * About CNI:: Description of the Compiled Native Interface
125 * System properties:: Modifying runtime behavior of the libgcj library
126 * Resources:: Where to look for more information
127 @end menu
128
129
130 @include gpl.texi
131
132 @include fdl.texi
133
134
135 @node Invoking gcj
136 @chapter Invoking gcj
137
138 @c man title gcj Ahead-of-time compiler for the Java language
139
140 @ignore
141 @c man begin SYNOPSIS gcj
142 gcj [@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}]
143 [@option{--CLASSPATH}=@var{path}] [@option{--classpath}=@var{path}]
144 [@option{-f}@var{option}@dots{}] [@option{--encoding}=@var{name}]
145 [@option{--main}=@var{classname}] [@option{-D}@var{name}[=@var{value}]@dots{}]
146 [@option{-C}] [@option{--resource} @var{resource-name}] [@option{-d} @var{directory}]
147 [@option{-W}@var{warn}@dots{}]
148 @var{sourcefile}@dots{}
149 @c man end
150 @c man begin SEEALSO gcj
151 gcc(1), gcjh(1), gjnih(1), gij(1), jv-scan(1), jcf-dump(1), gfdl(7),
152 and the Info entries for @file{gcj} and @file{gcc}.
153 @c man end
154 @end ignore
155
156 @c man begin DESCRIPTION gcj
157
158 As @command{gcj} is just another front end to @command{gcc}, it supports many
159 of the same options as gcc. @xref{Option Summary, , Option Summary,
160 gcc, Using the GNU Compiler Collection (GCC)}. This manual only documents the
161 options specific to @command{gcj}.
162
163 @c man end
164
165 @menu
166 * Input and output files::
167 * Input Options:: How gcj finds files
168 * Encodings:: Options controlling source file encoding
169 * Warnings:: Options controlling warnings specific to gcj
170 * Linking:: Options for making an executable
171 * Code Generation:: Options controlling the output of gcj
172 * Configure-time Options:: Options you won't use
173 @end menu
174
175 @c man begin OPTIONS gcj
176
177 @node Input and output files
178 @section Input and output files
179
180 A @command{gcj} command is like a @command{gcc} command, in that it
181 consists of a number of options and file names. The following kinds
182 of input file names are supported:
183
184 @table @gcctabopt
185 @item @var{file}.java
186 Java source files.
187 @item @var{file}.class
188 Java bytecode files.
189 @item @var{file}.zip
190 @itemx @var{file}.jar
191 An archive containing one or more @code{.class} files, all of
192 which are compiled. The archive may be compressed. Files in
193 an archive which don't end with @samp{.class} are treated as
194 resource files; they are compiled into the resulting object file
195 as @samp{core:} URLs.
196 @item @@@var{file}
197 A file containing a whitespace-separated list of input file names.
198 (Currently, these must all be @code{.java} source files, but that
199 may change.)
200 Each named file is compiled, just as if it had been on the command line.
201 @item @var{library}.a
202 @itemx @var{library}.so
203 @itemx -l@var{libname}
204 Libraries to use when linking. See the @command{gcc} manual.
205 @end table
206
207 You can specify more than one input file on the @command{gcj} command line,
208 in which case they will all be compiled. If you specify a
209 @code{-o @var{FILENAME}}
210 option, all the input files will be compiled together, producing a
211 single output file, named @var{FILENAME}.
212 This is allowed even when using @code{-S} or @code{-c},
213 but not when using @code{-C} or @code{--resource}.
214 (This is an extension beyond the what plain @command{gcc} allows.)
215 (If more than one input file is specified, all must currently
216 be @code{.java} files, though we hope to fix this.)
217
218 @node Input Options
219 @section Input Options
220
221 @cindex class path
222
223 @command{gcj} has options to control where it looks to find files it needs.
224 For instance, @command{gcj} might need to load a class that is referenced
225 by the file it has been asked to compile. Like other compilers for the
226 Java language, @command{gcj} has a notion of a @dfn{class path}. There are
227 several options and environment variables which can be used to
228 manipulate the class path. When @command{gcj} looks for a given class, it
229 searches the class path looking for matching @file{.class} or
230 @file{.java} file. @command{gcj} comes with a built-in class path which
231 points at the installed @file{libgcj.jar}, a file which contains all the
232 standard classes.
233
234 In the below, a directory or path component can refer either to an
235 actual directory on the filesystem, or to a @file{.zip} or @file{.jar}
236 file, which @command{gcj} will search as if it is a directory.
237
238 @table @gcctabopt
239 @item -I@var{dir}
240 All directories specified by @code{-I} are kept in order and prepended
241 to the class path constructed from all the other options. Unless
242 compatibility with tools like @code{javac} is important, we recommend
243 always using @code{-I} instead of the other options for manipulating the
244 class path.
245
246 @item --classpath=@var{path}
247 This sets the class path to @var{path}, a colon-separated list of paths
248 (on Windows-based systems, a semicolon-separate list of paths).
249 This does not override the builtin (``boot'') search path.
250
251 @item --CLASSPATH=@var{path}
252 Deprecated synonym for @code{--classpath}.
253
254 @item --bootclasspath=@var{path}
255 Where to find the standard builtin classes, such as @code{java.lang.String}.
256
257 @item --extdirs=@var{path}
258 For each directory in the @var{path}, place the contents of that
259 directory at the end of the class path.
260
261 @item CLASSPATH
262 This is an environment variable which holds a list of paths.
263 @end table
264
265 The final class path is constructed like so:
266
267 @itemize @bullet
268 @item
269 First come all directories specified via @code{-I}.
270
271 @item
272 If @option{--classpath} is specified, its value is appended.
273 Otherwise, if the @code{CLASSPATH} environment variable is specified,
274 then its value is appended.
275 Otherwise, the current directory (@code{"."}) is appended.
276
277 @item
278 If @code{--bootclasspath} was specified, append its value.
279 Otherwise, append the built-in system directory, @file{libgcj.jar}.
280
281 @item
282 Finally, if @code{--extdirs} was specified, append the contents of the
283 specified directories at the end of the class path. Otherwise, append
284 the contents of the built-in extdirs at @code{$(prefix)/share/java/ext}.
285 @end itemize
286
287 The classfile built by @command{gcj} for the class @code{java.lang.Object}
288 (and placed in @code{libgcj.jar}) contains a special zero length
289 attribute @code{gnu.gcj.gcj-compiled}. The compiler looks for this
290 attribute when loading @code{java.lang.Object} and will report an error
291 if it isn't found, unless it compiles to bytecode (the option
292 @code{-fforce-classes-archive-check} can be used to override this
293 behavior in this particular case.)
294
295 @table @gcctabopt
296 @item -fforce-classes-archive-check
297 This forces the compiler to always check for the special zero length
298 attribute @code{gnu.gcj.gcj-compiled} in @code{java.lang.Object} and
299 issue an error if it isn't found.
300 @end table
301
302 @node Encodings
303 @section Encodings
304
305 The Java programming language uses Unicode throughout. In an effort to
306 integrate well with other locales, @command{gcj} allows @file{.java} files
307 to be written using almost any encoding. @command{gcj} knows how to
308 convert these encodings into its internal encoding at compile time.
309
310 You can use the @code{--encoding=@var{NAME}} option to specify an
311 encoding (of a particular character set) to use for source files. If
312 this is not specified, the default encoding comes from your current
313 locale. If your host system has insufficient locale support, then
314 @command{gcj} assumes the default encoding to be the @samp{UTF-8} encoding
315 of Unicode.
316
317 To implement @code{--encoding}, @command{gcj} simply uses the host
318 platform's @code{iconv} conversion routine. This means that in practice
319 @command{gcj} is limited by the capabilities of the host platform.
320
321 The names allowed for the argument @code{--encoding} vary from platform
322 to platform (since they are not standardized anywhere). However,
323 @command{gcj} implements the encoding named @samp{UTF-8} internally, so if
324 you choose to use this for your source files you can be assured that it
325 will work on every host.
326
327
328 @node Warnings
329 @section Warnings
330
331 @command{gcj} implements several warnings. As with other generic
332 @command{gcc} warnings, if an option of the form @code{-Wfoo} enables a
333 warning, then @code{-Wno-foo} will disable it. Here we've chosen to
334 document the form of the warning which will have an effect -- the
335 default being the opposite of what is listed.
336
337 @table @gcctabopt
338 @item -Wredundant-modifiers
339 With this flag, @command{gcj} will warn about redundant modifiers. For
340 instance, it will warn if an interface method is declared @code{public}.
341
342 @item -Wextraneous-semicolon
343 This causes @command{gcj} to warn about empty statements. Empty statements
344 have been deprecated.
345
346 @item -Wno-out-of-date
347 This option will cause @command{gcj} not to warn when a source file is
348 newer than its matching class file. By default @command{gcj} will warn
349 about this.
350
351 @item -Wno-deprecated
352 Warn if a deprecated class, method, or field is referred to.
353
354 @item -Wunused
355 This is the same as @command{gcc}'s @code{-Wunused}.
356
357 @item -Wall
358 This is the same as @code{-Wredundant-modifiers -Wextraneous-semicolon
359 -Wunused}.
360 @end table
361
362
363 @node Linking
364 @section Linking
365
366 To turn a Java application into an executable program,
367 you need to link it with the needed libraries, just as for C or C++.
368 The linker by default looks for a global function named @code{main}.
369 Since Java does not have global functions, and a
370 collection of Java classes may have more than one class with a
371 @code{main} method, you need to let the linker know which of those
372 @code{main} methods it should invoke when starting the application.
373 You can do that in any of these ways:
374
375 @itemize @bullet
376 @item
377 Specify the class containing the desired @code{main} method
378 when you link the application, using the @code{--main} flag,
379 described below.
380 @item
381 Link the Java package(s) into a shared library (dll) rather than an
382 executable. Then invoke the application using the @code{gij} program,
383 making sure that @code{gij} can find the libraries it needs.
384 @item
385 Link the Java packages(s) with the flag @code{-lgij}, which links
386 in the @code{main} routine from the @code{gij} command.
387 This allows you to select the class whose @code{main} method you
388 want to run when you run the application. You can also use
389 other @code{gij} flags, such as @code{-D} flags to set properties.
390 Using the @code{-lgij} library (rather than the @code{gij} program
391 of the previous mechanism) has some advantages: it is compatible with
392 static linking, and does not require configuring or installing libraries.
393 @end itemize
394
395 These @code{gij} options relate to linking an executable:
396
397 @table @gcctabopt
398 @item --main=@var{CLASSNAME}
399 This option is used when linking to specify the name of the class whose
400 @code{main} method should be invoked when the resulting executable is
401 run.
402
403 @item -D@var{name}[=@var{value}]
404 This option can only be used with @code{--main}. It defines a system
405 property named @var{name} with value @var{value}. If @var{value} is not
406 specified then it defaults to the empty string. These system properties
407 are initialized at the program's startup and can be retrieved at runtime
408 using the @code{java.lang.System.getProperty} method.
409
410 @item -lgij
411 Create an application whose command-line processing is that
412 of the @code{gij} command.
413
414 This option is an alternative to using @code{--main}; you cannot use both.
415 @end table
416
417 @node Code Generation
418 @section Code Generation
419
420 In addition to the many @command{gcc} options controlling code generation,
421 @command{gcj} has several options specific to itself.
422
423 @table @gcctabopt
424
425 @item -C
426 This option is used to tell @command{gcj} to generate bytecode
427 (@file{.class} files) rather than object code.
428
429 @item --resource @var{resource-name}
430 This option is used to tell @command{gcj} to compile the contents of a
431 given file to object code so it may be accessed at runtime with the core
432 protocol handler as @samp{core:/@var{resource-name}}. Note that
433 @var{resource-name} is the name of the resource as found at runtime; for
434 instance, it could be used in a call to @code{ResourceBundle.getBundle}.
435 The actual file name to be compiled this way must be specified
436 separately.
437
438 @item -d @var{directory}
439 When used with @code{-C}, this causes all generated @file{.class} files
440 to be put in the appropriate subdirectory of @var{directory}. By
441 default they will be put in subdirectories of the current working
442 directory.
443
444 @item -fno-bounds-check
445 By default, @command{gcj} generates code which checks the bounds of all
446 array indexing operations. With this option, these checks are omitted, which
447 can improve performance for code that uses arrays extensively. Note that this
448 can result in unpredictable behavior if the code in question actually does
449 violate array bounds constraints. It is safe to use this option if you are
450 sure that your code will never throw an @code{ArrayIndexOutOfBoundsException}.
451
452 @item -fno-store-check
453 Don't generate array store checks. When storing objects into arrays, a runtime
454 check is normally generated in order to ensure that the object is assignment
455 compatible with the component type of the array (which may not be known
456 at compile-time). With this option, these checks are omitted. This can
457 improve performance for code which stores objects into arrays frequently.
458 It is safe to use this option if you are sure your code will never throw an
459 @code{ArrayStoreException}.
460
461 @item -fjni
462 With @command{gcj} there are two options for writing native methods: CNI
463 and JNI@. By default @command{gcj} assumes you are using CNI@. If you are
464 compiling a class with native methods, and these methods are implemented
465 using JNI, then you must use @code{-fjni}. This option causes
466 @command{gcj} to generate stubs which will invoke the underlying JNI
467 methods.
468
469 @item -fno-assert
470 Don't recognize the @code{assert} keyword. This is for compatibility
471 with older versions of the language specification.
472
473 @item -fno-optimize-static-class-initialization
474 When the optimization level is greater or equal to @code{-O2},
475 @command{gcj} will try to optimize the way calls into the runtime are made
476 to initialize static classes upon their first use (this optimization
477 isn't carried out if @code{-C} was specified.) When compiling to native
478 code, @code{-fno-optimize-static-class-initialization} will turn this
479 optimization off, regardless of the optimization level in use.
480
481 @item --disable-assertions[=@var{class-or-package}]
482 Don't include code for checking assertions in the compiled code.
483 If @code{=@var{class-or-package}} is missing disables assertion code
484 generation for all classes, unless overridden by a more
485 specific @code{--enable-assertions} flag.
486 If @var{class-or-package} is a class name, only disables generating
487 assertion checks within the named class or its inner classes.
488 If @var{class-or-package} is a package name, disables generating
489 assertion checks within the named package or a subpackage.
490
491 By default, assertions are enabled when generating class files
492 or when not optimizing, and disabled when generating optimized binaries.
493
494 @item --enable-assertions[=@var{class-or-package}]
495 Generates code to check assertions. The option is perhaps misnamed,
496 as you still need to turn on assertion checking at run-time,
497 and we don't support any easy way to do that.
498 So this flag isn't very useful yet, except to partially override
499 @code{--disable-assertions}.
500
501 @item -findirect-dispatch
502 @command{gcj} has a special binary compatibility ABI, which is enabled
503 by the @code{-findirect-dispatch} option. In this mode, the code
504 generated by @command{gcj} honors the binary compatibility guarantees
505 in the Java Language Specification, and the resulting object files do
506 not need to be directly linked against their dependencies. Instead,
507 all dependencies are looked up at runtime. This allows free mixing of
508 interpreted and compiled code.
509
510 Note that, at present, @code{-findirect-dispatch} can only be used
511 when compiling @file{.class} files. It will not work when compiling
512 from source. CNI also does not yet work with the binary compatibility
513 ABI. These restrictions will be lifted in some future release.
514
515 However, if you compile CNI code with the standard ABI, you can call
516 it from code built with the binary compatibility ABI.
517
518 @item -fbootstrap-classes
519 This option can be use to tell @code{libgcj} that the compiled classes
520 should be loaded by the bootstrap loader, not the system class loader.
521 By default, if you compile a class and link it into an executable, it
522 will be treated as if it was loaded using the system class loader.
523 This is convenient, as it means that things like
524 @code{Class.forName()} will search @samp{CLASSPATH} to find the
525 desired class.
526
527 @end table
528
529
530 @node Configure-time Options
531 @section Configure-time Options
532
533 Some @command{gcj} code generations options affect the resulting ABI, and
534 so can only be meaningfully given when @code{libgcj}, the runtime
535 package, is configured. @code{libgcj} puts the appropriate options from
536 this group into a @samp{spec} file which is read by @command{gcj}. These
537 options are listed here for completeness; if you are using @code{libgcj}
538 then you won't want to touch these options.
539
540 @table @gcctabopt
541 @item -fuse-boehm-gc
542 This enables the use of the Boehm GC bitmap marking code. In particular
543 this causes @command{gcj} to put an object marking descriptor into each
544 vtable.
545
546 @item -fhash-synchronization
547 By default, synchronization data (the data used for @code{synchronize},
548 @code{wait}, and @code{notify}) is pointed to by a word in each object.
549 With this option @command{gcj} assumes that this information is stored in a
550 hash table and not in the object itself.
551
552 @item -fuse-divide-subroutine
553 On some systems, a library routine is called to perform integer
554 division. This is required to get exception handling correct when
555 dividing by zero.
556
557 @item -fcheck-references
558 On some systems it's necessary to insert inline checks whenever
559 accessing an object via a reference. On other systems you won't need
560 this because null pointer accesses are caught automatically by the
561 processor.
562 @end table
563
564 @c man end
565
566 @node Compatibility
567 @chapter Compatibility with the Java Platform
568
569 As we believe it is important that the Java platform not be fragmented,
570 @command{gcj} and @code{libgcj} try to conform to the relevant Java
571 specifications. However, limited manpower and incomplete and unclear
572 documentation work against us. So, there are caveats to using
573 @command{gcj}.
574
575 @menu
576 * Limitations::
577 * Extensions::
578 @end menu
579
580 @node Limitations
581 @section Standard features not yet supported
582
583 This list of compatibility issues is by no means complete.
584
585 @itemize @bullet
586 @item
587 @command{gcj} implements the JDK 1.2 language. It supports inner classes
588 and the new 1.4 @code{assert} keyword. It does not yet support the Java 2
589 @code{strictfp} keyword (it recognizes the keyword but ignores it).
590
591 @item
592 @code{libgcj} is largely compatible with the JDK 1.2 libraries.
593 However, @code{libgcj} is missing many packages, most notably
594 @code{java.awt}. There are also individual missing classes and methods.
595 We currently do not have a list showing differences between
596 @code{libgcj} and the Java 2 platform.
597
598 @item
599 Sometimes the @code{libgcj} implementation of a method or class differs
600 from the JDK implementation. This is not always a bug. Still, if it
601 affects you, it probably makes sense to report it so that we can discuss
602 the appropriate response.
603
604 @item
605 @command{gcj} does not currently allow for piecemeal replacement of
606 components within @code{libgcj}. Unfortunately, programmers often want
607 to use newer versions of certain packages, such as those provided by
608 the Apache Software Foundation's Jakarta project. This has forced us
609 to place the @code{org.w3c.dom} and @code{org.xml.sax} packages into
610 their own libraries, separate from @code{libgcj}. If you intend to
611 use these classes, you must link them explicitly with
612 @code{-l-org-w3c-dom} and @code{-l-org-xml-sax}. Future versions of
613 @command{gcj} may not have this restriction.
614 @end itemize
615
616 @node Extensions
617 @section Extra features unique to gcj
618
619 The main feature of @command{gcj} is that it can compile programs written in
620 the Java programming language to native code. Most extensions that have been
621 added are to facilitate this functionality.
622
623 @itemize @bullet
624 @item
625 @command{gcj} makes it easy and efficient to mix code written in Java and C++.
626 @xref{About CNI}, for more info on how to use this in your programs.
627
628 @item
629 When you compile your classes into a shared library they can be automatically
630 loaded by the @code{libgcj} system classloader. When trying to load a class
631 @code{gnu.pkg.SomeClass} the system classloader will first try to load the
632 shared library @file{lib-gnu-pkg-SomeClass.so}, if that fails to load the
633 class then it will try to load @file{lib-gnu-pkg.so} and finally when the
634 class is still not loaded it will try to load @file{lib-gnu.so}. Note that
635 all @samp{.}s will be transformed into @samp{-}s and that searching
636 for inner classes starts with their outermost outer class. If the class
637 cannot be found this way the system classloader tries to use
638 the @code{libgcj} bytecode interpreter to load the class from the standard
639 classpath. This process can be controlled to some degree via the
640 @code{gnu.gcj.runtime.VMClassLoader.library_control} property;
641 @xref{libgcj Runtime Properties}.
642
643 @item
644 @code{libgcj} includes a special @samp{gcjlib} URL type. A URL of
645 this form is like a @code{jar} URL, and looks like
646 @samp{gcjlib:/path/to/shared/library.so!/path/to/resource}. An access
647 to one of these URLs causes the shared library to be @code{dlopen()}d,
648 and then the resource is looked for in that library. These URLs are
649 most useful when used in conjunction with @code{java.net.URLClassLoader}.
650 Note that, due to implementation limitations, currently any such URL
651 can be accessed by only one class loader, and libraries are never
652 unloaded. This means some care must be exercised to make sure that
653 a @code{gcjlib} URL is not accessed by more than one class loader at once.
654 In a future release this limitation will be lifted, and such
655 libraries will be mapped privately.
656
657 @item
658 A program compiled by @command{gcj} will examine the
659 @env{GCJ_PROPERTIES} environment variable and change its behavior in
660 some ways. In particular @env{GCJ_PROPERTIES} holds a list of
661 assignments to global properties, such as would be set with the
662 @option{-D} option to @command{java}. For instance,
663 @samp{java.compiler=gcj} is a valid (but currently meaningless)
664 setting.
665 @cindex GCJ_PROPERTIES
666 @vindex GCJ_PROPERTIES
667
668 @end itemize
669
670
671 @node Invoking gcjh
672 @chapter Invoking gcjh
673
674 @c man title gcjh generate header files from Java class files
675
676 @c man begin DESCRIPTION gcjh
677
678 The @code{gcjh} program is used to generate header files from class
679 files. It can generate both CNI and JNI header files, as well as stub
680 implementation files which can be used as a basis for implementing the
681 required native methods.
682
683 @c man end
684
685 @ignore
686 @c man begin SYNOPSIS gcjh
687 gcjh [@option{-stubs}] [@option{-jni}]
688 [@option{-force}] [@option{-old}] [@option{-trace}] [@option{-J} @var{option}]
689 [@option{-add} @var{text}] [@option{-append} @var{text}] [@option{-friend} @var{text}]
690 [@option{-preprend} @var{text}]
691 [@option{--classpath}=@var{path}] [@option{--CLASSPATH}=@var{path}]
692 [@option{--bootclasspath}=@var{path}]
693 [@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}]
694 [@option{-o} @var{file}] [@option{-td} @var{dir}]
695 [@option{-M}] [@option{-MM}] [@option{-MD}] [@option{-MMD}]
696 [@option{--version}] [@option{--help}] [@option{-v}] [@option{--verbose}]
697 @var{classname}@dots{}
698 @c man end
699 @c man begin SEEALSO gcjh
700 gcc(1), gcj(1), gij(1), jv-scan(1), jcf-dump(1), gfdl(7),
701 and the Info entries for @file{gcj} and @file{gcc}.
702 @c man end
703 @end ignore
704
705 @c man begin OPTIONS gcjh
706
707 @table @gcctabopt
708 @item -stubs
709 This causes @code{gcjh} to generate stub files instead of header files.
710 By default the stub file will be named after the class, with a suffix of
711 @samp{.cc}. In JNI mode, the default output file will have the suffix
712 @samp{.c}.
713
714 @item -jni
715 This tells @code{gcjh} to generate a JNI header or stub. By default,
716 CNI headers are generated.
717
718 @item -force
719 This option forces @code{gcjh} to write the output file.
720
721 @item -old
722 This option is accepted but ignored for compatibility.
723
724 @item -trace
725 This option is accepted but ignored for compatibility.
726
727 @item -J @var{option}
728 This option is accepted but ignored for compatibility.
729
730 @item -add @var{text}
731 Inserts @var{text} into the class body. This is ignored in JNI mode.
732
733 @item -append @var{text}
734 Inserts @var{text} into the header file after the class declaration.
735 This is ignored in JNI mode.
736
737 @item -friend @var{text}
738 Inserts @var{text} into the class as a @code{friend} declaration.
739 This is ignored in JNI mode.
740
741 @item -prepend @var{text}
742 Inserts @var{text} into the header file before the class declaration.
743 This is ignored in JNI mode.
744
745 @item --classpath=@var{path}
746 @itemx --CLASSPATH=@var{path}
747 @itemx --bootclasspath=@var{path}
748 @itemx -I@var{directory}
749 @itemx -d @var{directory}
750 @itemx -o @var{file}
751 These options are all identical to the corresponding @command{gcj} options.
752
753 @item -o @var{file}
754 Sets the output file name. This cannot be used if there is more than
755 one class on the command line.
756
757 @item -td @var{directory}
758 Sets the name of the directory to use for temporary files.
759
760 @item -M
761 Print all dependencies to stdout; suppress ordinary output.
762
763 @item -MM
764 Print non-system dependencies to stdout; suppress ordinary output.
765
766 @item -MD
767 Print all dependencies to stdout.
768
769 @item -MMD
770 Print non-system dependencies to stdout.
771
772 @item --help
773 Print help about @code{gcjh} and exit. No further processing is done.
774
775 @item --version
776 Print version information for @code{gcjh} and exit. No further
777 processing is done.
778
779 @item -v, --verbose
780 Print extra information while running.
781 @end table
782
783 All remaining options are considered to be names of classes.
784
785 @c man end
786
787 @node Invoking gjnih
788 @chapter Invoking gjnih
789
790 @c man title gjnih generate JNI header files from Java class files
791
792 @c man begin DESCRIPTION gjnih
793
794 The @code{gjnih} program is used to generate JNI header files from class
795 files. Running it is equivalent to running @code{gcjh -jni}.
796
797 @c man end
798
799 @ignore
800 @c man begin SYNOPSIS gjnih
801 gjnih [@option{-stubs}] [@option{-jni}]
802 [@option{-force}] [@option{-old}] [@option{-trace}] [@option{-J} @var{option}]
803 [@option{-add} @var{text}] [@option{-append} @var{text}] [@option{-friend} @var{text}]
804 [@option{-preprend} @var{text}]
805 [@option{--classpath}=@var{path}] [@option{--CLASSPATH}=@var{path}]
806 [@option{--bootclasspath}=@var{path}]
807 [@option{-I}@var{dir}@dots{}] [@option{-d} @var{dir}@dots{}]
808 [@option{-o} @var{file}] [@option{-td} @var{dir}]
809 [@option{-M}] [@option{-MM}] [@option{-MD}] [@option{-MMD}]
810 [@option{--version}] [@option{--help}] [@option{-v}] [@option{--verbose}]
811 @var{classname}@dots{}
812 @c man end
813 @c man begin SEEALSO gjnih
814 gcc(1), gcj(1), gcjh(1), gij(1), jv-scan(1), jcf-dump(1), gfdl(7),
815 and the Info entries for @file{gcj} and @file{gcc}.
816 @c man end
817 @end ignore
818
819 @c man begin OPTIONS gjnih
820
821 @table @gcctabopt
822 @item -stubs
823 This causes @code{gjnih} to generate stub files instead of header files.
824 By default the stub file will be named after the class, with a suffix of
825 @samp{.c}.
826
827 @item -jni
828 This option specifies the default behavior which is to generate a JNI
829 header or stub.
830
831 @item -force
832 This option forces @code{gjnih} to write the output file.
833
834 @item -old
835 This option is accepted but ignored for compatibility.
836
837 @item -trace
838 This option is accepted but ignored for compatibility.
839
840 @item -J @var{option}
841 This option is accepted but ignored for compatibility.
842
843 @item -add @var{text}
844 Inserts @var{text} into the class body. This is ignored in by
845 @code{gjnih}.
846
847 @item -append @var{text}
848 Inserts @var{text} into the header file after the class declaration.
849 This is ignored in by @code{gjnih}.
850
851 @item -friend @var{text}
852 Inserts @var{text} into the class as a @code{friend} declaration.
853 This is ignored by @code{gjnih}.
854
855 @item -prepend @var{text}
856 Inserts @var{text} into the header file before the class declaration.
857 This is ignored in by @code{gjnih}.
858
859 @item --classpath=@var{path}
860 @itemx --CLASSPATH=@var{path}
861 @itemx --bootclasspath=@var{path}
862 @itemx -I@var{directory}
863 @itemx -d @var{directory}
864 @itemx -o @var{file}
865 These options are all identical to the corresponding @command{gcj} options.
866
867 @item -o @var{file}
868 Sets the output file name. This cannot be used if there is more than
869 one class on the command line.
870
871 @item -td @var{directory}
872 Sets the name of the directory to use for temporary files.
873
874 @item -M
875 Print all dependencies to stdout; suppress ordinary output.
876
877 @item -MM
878 Print non-system dependencies to stdout; suppress ordinary output.
879
880 @item -MD
881 Print all dependencies to stdout.
882
883 @item -MMD
884 Print non-system dependencies to stdout.
885
886 @item --help
887 Print help about @code{gjnih} and exit. No further processing is done.
888
889 @item --version
890 Print version information for @code{gjnih} and exit. No further
891 processing is done.
892
893 @item -v, --verbose
894 Print extra information while running.
895 @end table
896
897 All remaining options are considered to be names of classes.
898
899 @c man end
900
901 @node Invoking jv-scan
902 @chapter Invoking jv-scan
903
904 @c man title jv-scan print information about Java source file
905
906 @c man begin DESCRIPTION jv-scan
907
908 The @code{jv-scan} program can be used to print information about a Java
909 source file (@file{.java} file).
910
911 @c man end
912
913 @ignore
914 @c man begin SYNOPSIS jv-scan
915 jv-scan [@option{--no-assert}] [@option{--complexity}]
916 [@option{--encoding}=@var{name}] [@option{--print-main}]
917 [@option{--list-class}] [@option{--list-filename}]
918 [@option{--version}] [@option{--help}]
919 [@option{-o} @var{file}] @var{inputfile}@dots{}
920 @c man end
921 @c man begin SEEALSO jv-scan
922 gcc(1), gcj(1), gcjh(1), gij(1), jcf-dump(1), gfdl(7),
923 and the Info entries for @file{gcj} and @file{gcc}.
924 @c man end
925 @end ignore
926
927 @c man begin OPTIONS jv-scan
928
929 @table @gcctabopt
930 @item --no-assert
931 Don't recognize the @code{assert} keyword, for backwards compatibility
932 with older versions of the language specification.
933
934 @item --complexity
935 This prints a complexity measure, related to cyclomatic complexity, for
936 each input file.
937
938 @item --encoding=@var{name}
939 This works like the corresponding @command{gcj} option.
940
941 @item --print-main
942 This prints the name of the class in this file containing a @code{main}
943 method.
944
945 @item --list-class
946 This lists the names of all classes defined in the input files.
947
948 @item --list-filename
949 If @code{--list-class} is given, this option causes @code{jv-scan} to
950 also print the name of the file in which each class was found.
951
952 @item -o @var{file}
953 Print output to the named file.
954
955 @item --help
956 Print help, then exit.
957
958 @item --version
959 Print version number, then exit.
960 @end table
961
962 @c man end
963
964 @node Invoking jcf-dump
965 @chapter Invoking jcf-dump
966
967 @c man title jcf-dump print information about Java class files
968
969 @ignore
970 @c man begin SYNOPSIS jcf-dump
971 jcf-dump [@option{-c}] [@option{--javap}]
972 [@option{--classpath}=@var{path}] [@option{--CLASSPATH}=@var{path}]
973 [@option{-I}@var{dir}@dots{}] [@option{-o} @var{file}]
974 [@option{--version}] [@option{--help}] [@option{-v}] [@option{--verbose}]
975 @var{classname}@dots{}
976 @c man end
977 @c man begin SEEALSO jcf-dump
978 gcc(1), gcj(1), gcjh(1), gij(1), jcf-dump(1), gfdl(7),
979 and the Info entries for @file{gcj} and @file{gcc}.
980 @c man end
981 @end ignore
982
983 @c man begin DESCRIPTION jcf-dump
984
985 This is a class file examiner, similar to @code{javap}. It will print
986 information about a number of classes, which are specified by class name
987 or file name.
988
989 @c man end
990
991 @c man begin OPTIONS jcf-dump
992
993 @table @gcctabopt
994 @item -c
995 Disassemble method bodies. By default method bodies are not printed.
996
997 @item --print-constants
998 Print the constant pool. When printing a reference to a constant
999 also print its index in the constant pool.
1000
1001 @item --javap
1002 Generate output in @code{javap} format. The implementation of this
1003 feature is very incomplete.
1004
1005 @item --classpath=@var{path}
1006 @itemx --CLASSPATH=@var{path}
1007 @itemx -I@var{directory}
1008 @itemx -o @var{file}
1009 These options as the same as the corresponding @command{gcj} options.
1010
1011 @item --help
1012 Print help, then exit.
1013
1014 @item --version
1015 Print version number, then exit.
1016
1017 @item -v, --verbose
1018 Print extra information while running.
1019 Implies @code{--print-constants}.
1020 @end table
1021
1022 @c man end
1023
1024 @node Invoking gij
1025 @chapter Invoking gij
1026
1027 @c man title gij GNU interpreter for Java bytecode
1028
1029 @ignore
1030 @c man begin SYNOPSIS gij
1031 gij [@option{OPTION}] @dots{} @var{JARFILE} [@var{ARGS}@dots{}]
1032
1033 gij [@option{-jar}] [@option{OPTION}] @dots{} @var{CLASS} [@var{ARGS}@dots{}]
1034 [@option{-cp} @var{path}] [@option{-classpath} @var{path}]
1035 [@option{-D}@var{name}[=@var{value}]@dots{}]
1036 [@option{-ms=}@var{number}] [@option{-mx=}@var{number}]
1037 [@option{-X@var{argument}}] [@option{-verbose}] [@option{-verbose:class}]
1038 [@option{--showversion}] [@option{--version}] [@option{--help}][@option{-?}]
1039 @c man end
1040 @c man begin SEEALSO gij
1041 gcc(1), gcj(1), gcjh(1), jv-scan(1), jcf-dump(1), gfdl(7),
1042 and the Info entries for @file{gcj} and @file{gcc}.
1043 @c man end
1044 @end ignore
1045
1046 @c man begin DESCRIPTION gij
1047
1048 @code{gij} is a Java bytecode interpreter included with @code{libgcj}.
1049 @code{gij} is not available on every platform; porting it requires a
1050 small amount of assembly programming which has not been done for all the
1051 targets supported by @command{gcj}.
1052
1053 The primary argument to @code{gij} is the name of a class or, with
1054 @code{-jar}, a jar file. Options before this argument are interpreted
1055 by @code{gij}; remaining options are passed to the interpreted program.
1056
1057 If a class name is specified and this class does not have a @code{main}
1058 method with the appropriate signature (a @code{static void} method with
1059 a @code{String[]} as its sole argument), then @code{gij} will print an
1060 error and exit.
1061
1062 If a jar file is specified then @code{gij} will use information in it to
1063 determine which class' @code{main} method will be invoked.
1064
1065 @code{gij} will invoke the @code{main} method with all the remaining
1066 command-line options.
1067
1068 Note that @code{gij} is not limited to interpreting code. Because
1069 @code{libgcj} includes a class loader which can dynamically load shared
1070 objects, it is possible to give @code{gij} the name of a class which has
1071 been compiled and put into a shared library on the class path.
1072
1073 @c man end
1074
1075 @c man begin OPTIONS gij
1076
1077 @table @gcctabopt
1078 @item -cp @var{path}
1079 @itemx -classpath @var{path}
1080 Set the initial class path. The class path is used for finding
1081 class and resource files. If specified, this option overrides the
1082 @code{CLASSPATH} environment variable. Note that this option is
1083 ignored if @code{-jar} is used.
1084
1085 @item -D@var{name}[=@var{value}]
1086 This defines a system property named @var{name} with value @var{value}.
1087 If @var{value} is not specified then it defaults to the empty string.
1088 These system properties are initialized at the program's startup and can
1089 be retrieved at runtime using the @code{java.lang.System.getProperty}
1090 method.
1091
1092 @item -ms=@var{number}
1093 Equivalent to @code{-Xms}.
1094
1095 @item -mx=@var{number}
1096 Equivalent to @code{-Xmx}.
1097
1098 @item -X
1099 @itemx -X@var{argument}
1100 Supplying @code{-X} by itself will cause @code{gij} to list all the
1101 supported @code{-X} options. Currently these options are supported:
1102
1103 @table @gcctabopt
1104 @item -Xms@var{size}
1105 Set the initial heap size.
1106
1107 @item -Xmx@var{size}
1108 Set the maximum heap size.
1109 @end table
1110
1111 Unrecognized @code{-X} options are ignored, for compatibility with
1112 other runtimes.
1113
1114 @item -jar
1115 This indicates that the name passed to @code{gij} should be interpreted
1116 as the name of a jar file, not a class.
1117
1118 @item --help
1119 @itemx -?
1120 Print help, then exit.
1121
1122 @item --showversion
1123 Print version number and continue.
1124
1125 @item --fullversion
1126 Print detailed version information, then exit.
1127
1128 @item --version
1129 Print version number, then exit.
1130
1131 @item -verbose
1132 @itemx -verbose:class
1133 Each time a class is initialized, print a short message on standard error.
1134 @end table
1135
1136 @code{gij} also recognizes and ignores the following options, for
1137 compatibility with existing application launch scripts:
1138 @code{-client}, @code{-server}, @code{-hotspot}, @code{-jrockit},
1139 @code{-agentlib}, @code{-agentpath}, @code{-debug}, @code{-d32},
1140 @code{-d64}, @code{-javaagent} and @code{-noclassgc}.
1141
1142 @c man end
1143
1144 @node Invoking gcj-dbtool
1145 @chapter Invoking gcj-dbtool.
1146
1147 @c man title gcj-dbtool Manipulate class file mapping databases for libgcj
1148
1149 @ignore
1150 @c man begin SYNOPSIS gcj-dbtool
1151 gcj-dbtool @option{OPTION} @var{DBFILE} [@option{MORE}] @dots{}
1152
1153 gcj-dbtool [@option{-0}] [@option{-}] [@option{-n}] [@option{-a}] [@option{-f}]
1154 [@option{-t}] [@option{-l}] [@option{-p} [@var{LIBDIR}]]
1155 [@option{-v}] [@option{-m}] [@option{--version}] [@option{--help}]
1156
1157 @c man end
1158 @c man begin SEEALSO gij
1159 gcc(1), gcj(1), gcjh(1), jv-scan(1), jcf-dump(1), gfdl(7),
1160 and the Info entries for @file{gcj} and @file{gcc}.
1161 @c man end
1162 @end ignore
1163
1164 @c man begin DESCRIPTION gcj-dbtool
1165
1166 @code{gcj-dbtool} is a tool for creating and manipulating class file
1167 mapping databases. @code{libgcj} can use these databases to find a
1168 shared library corresponding to the bytecode representation of a
1169 class. This functionality is useful for ahead-of-time compilation of
1170 a program that has no knowledge of @code{gcj}.
1171
1172 @code{gcj-dbtool} works best if all the jar files added to it are
1173 compiled using @code{-findirect-dispatch}.
1174
1175 Note that @code{gcj-dbtool} is currently available as ``preview
1176 technology''. We believe it is a reasonable way to allow
1177 application-transparent ahead-of-time compilation, but this is an
1178 unexplored area. We welcome your comments.
1179
1180 @c man end
1181
1182 @c man begin OPTIONS gcj-dbtool
1183
1184 @table @gcctabopt
1185 @item -n @var{DBFILE} [@var{SIZE}]
1186 This creates a new database. Currently, databases cannot be resized;
1187 you can choose a larger initial size if desired. The default size is
1188 32,749.
1189
1190 @item -a @var{DBFILE} @var{JARFILE} @var{LIB}
1191 @itemx -f @var{DBFILE} @var{JARFILE} @var{LIB}
1192 This adds a jar file to the database. For each class file in the jar,
1193 a cryptographic signature of the bytecode representation of the class
1194 is recorded in the database. At runtime, a class is looked up by its
1195 signature and the compiled form of the class is looked for in the
1196 corresponding shared library. The @option{-a} option will verify
1197 that @var{LIB} exists before adding it to the database; @option{-f}
1198 skips this check.
1199
1200 @item [@option{-}][@option{-0}] -m @var{DBFILE} @var{DBFILE},[@var{DBFILE}]
1201 Merge a number of databases. The output database overwrites any
1202 existing database. To add databases into an existing database,
1203 include the destination in the list of sources.
1204
1205 If @option{-} or @option{-0} are used, the list of files to read is
1206 taken from standard input instead of the command line. For
1207 @option{-0}, Input filenames are terminated by a null character
1208 instead of by whitespace. Useful when arguments might contain white
1209 space. The GNU find -print0 option produces input suitable for this
1210 mode.
1211
1212 @item -t @var{DBFILE}
1213 Test a database.
1214
1215 @item -l @var{DBFILE}
1216 List the contents of a database.
1217
1218 @item -p
1219 Print the name of the default database. If there is no default
1220 database, this prints a blank line. If @var{LIBDIR} is specified, use
1221 it instead of the default library directory component of the database
1222 name.
1223
1224 @item --help
1225 Print a help message, then exit.
1226
1227 @item --version
1228 @itemx -v
1229 Print version information, then exit.
1230
1231 @end table
1232
1233 @c man end
1234
1235 @node Invoking jv-convert
1236 @chapter Invoking jv-convert
1237
1238 @c man title jv-convert Convert file from one encoding to another
1239
1240 @c man begin SYNOPSIS jv-convert
1241 @command{jv-convert} [@option{OPTION}] @dots{} [@var{INPUTFILE} [@var{OUTPUTFILE}]]
1242 @ignore
1243
1244 [@option{--encoding} @var{name}]
1245 [@option{--from} @var{name}]
1246 [@option{--to} @var{name}]
1247 [@option{-i} @var{file}] [@option{-o} @var{file}]
1248 [@option{--reverse}] [@option{--help}] [@option{--version}]
1249 @end ignore
1250 @c man end
1251
1252 @c man begin DESCRIPTION jv-convert
1253
1254 @command{jv-convert} is a utility included with @code{libgcj} which
1255 converts a file from one encoding to another. It is similar to the Unix
1256 @command{iconv} utility.
1257
1258 The encodings supported by @command{jv-convert} are platform-dependent.
1259 Currently there is no way to get a list of all supported encodings.
1260
1261 @c man end
1262
1263 @c man begin OPTIONS jv-convert
1264
1265 @table @gcctabopt
1266 @item --encoding @var{name}
1267 @itemx --from @var{name}
1268 Use @var{name} as the input encoding. The default is the current
1269 locale's encoding.
1270
1271 @item --to @var{name}
1272 Use @var{name} as the output encoding. The default is the
1273 @code{JavaSrc} encoding; this is ASCII with @samp{\u} escapes for
1274 non-ASCII characters.
1275
1276 @item -i @var{file}
1277 Read from @var{file}. The default is to read from standard input.
1278
1279 @item -o @var{file}
1280 Write to @var{file}. The default is to write to standard output.
1281
1282 @item --reverse
1283 Swap the input and output encodings.
1284
1285 @item --help
1286 Print a help message, then exit.
1287
1288 @item --version
1289 Print version information, then exit.
1290 @end table
1291
1292 @c man end
1293
1294 @node Invoking grmic
1295 @chapter Invoking grmic
1296
1297 @c man title grmic Generate stubs for Remote Method Invocation
1298
1299 @c man begin SYNOPSIS grmic
1300 @command{grmic} [@option{OPTION}] @dots{} @var{class} @dots{}
1301 @ignore
1302 [@option{-keep}]
1303 [@option{-keepgenerated}]
1304 [@option{-v1.1}]
1305 [@option{-vcompat}]
1306 [@option{-v1.2}]
1307 [@option{-nocompile}]
1308 [@option{-verbose}]
1309 [@option{-d} @var{directory}]
1310 [@option{-help}]
1311 [@option{-version}]
1312 @end ignore
1313 @c man end
1314
1315 @c man begin DESCRIPTION grmic
1316
1317 @command{grmic} is a utility included with @code{libgcj} which generates
1318 stubs for remote objects.
1319
1320 @c FIXME: Add real information here.
1321 @c This really isn't much more than the --help output.
1322
1323 Note that this program isn't yet fully compatible with the JDK
1324 @command{grmic}. Some options, such as @option{-classpath}, are
1325 recognized but currently ignored. We have left these options
1326 undocumented for now.
1327
1328 Long options can also be given with a GNU-style leading @samp{--}. For
1329 instance, @option{--help} is accepted.
1330
1331 @c man end
1332
1333 @c man begin OPTIONS grmic
1334
1335 @table @gcctabopt
1336 @item -keep
1337 @itemx -keepgenerated
1338 By default, @command{grmic} deletes intermediate files. Either of these
1339 options causes it not to delete such files.
1340
1341 @item -v1.1
1342 Cause @command{grmic} to create stubs and skeletons for the 1.1
1343 protocol version.
1344
1345 @item -vcompat
1346 Cause @command{grmic} to create stubs and skeletons compatible with both
1347 the 1.1 and 1.2 protocol versions. This is the default.
1348
1349 @item -v1.2
1350 Cause @command{grmic} to create stubs and skeletons for the 1.2
1351 protocol version.
1352
1353 @item -nocompile
1354 Don't compile the generated files.
1355
1356 @item -verbose
1357 Print information about what @command{grmic} is doing.
1358
1359 @item -d @var{directory}
1360 Put output files in @var{directory}. By default the files are put in
1361 the current working directory.
1362
1363 @item -help
1364 Print a help message, then exit.
1365
1366 @item -version
1367 Print version information, then exit.
1368 @end table
1369
1370 @c man end
1371
1372
1373 @node Invoking grmiregistry
1374 @chapter Invoking grmiregistry
1375
1376 @c man title grmiregistry Remote object registry
1377
1378 @c man begin SYNOPSIS grmiregistry
1379 @command{grmic} [@option{OPTION}] @dots{} [@var{port}]
1380 @ignore
1381 [@option{--help}]
1382 [@option{--version}]
1383 @end ignore
1384 @c man end
1385
1386 @c man begin DESCRIPTION grmiregistry
1387
1388 @command{grmiregistry} starts a remote object registry on the current
1389 host. If no port number is specified, then port 1099 is used.
1390
1391 @c FIXME: Add real information here.
1392 @c This really isn't much more than the --help output.
1393
1394 @c man end
1395
1396 @c man begin OPTIONS grmiregistry
1397
1398 @table @gcctabopt
1399 @item --help
1400 Print a help message, then exit.
1401
1402 @item --version
1403 Print version information, then exit.
1404 @end table
1405
1406 @c man end
1407
1408
1409 @node About CNI
1410 @chapter About CNI
1411
1412 This documents CNI, the Compiled Native Interface,
1413 which is is a convenient way to write Java native methods using C++.
1414 This is a more efficient, more convenient, but less portable
1415 alternative to the standard JNI (Java Native Interface).
1416
1417 @menu
1418 * Basic concepts:: Introduction to using CNI@.
1419 * Packages:: How packages are mapped to C++.
1420 * Primitive types:: Handling Java types in C++.
1421 * Interfaces:: How Java interfaces map to C++.
1422 * Objects and Classes:: C++ and Java classes.
1423 * Class Initialization:: How objects are initialized.
1424 * Object allocation:: How to create Java objects in C++.
1425 * Memory allocation:: How to allocate and free memory.
1426 * Arrays:: Dealing with Java arrays in C++.
1427 * Methods:: Java methods in C++.
1428 * Strings:: Information about Java Strings.
1429 * Mixing with C++:: How CNI can interoperate with C++.
1430 * Exception Handling:: How exceptions are handled.
1431 * Synchronization:: Synchronizing between Java and C++.
1432 * Invocation:: Starting the Java runtime from C++.
1433 * Reflection:: Using reflection from C++.
1434 @end menu
1435
1436
1437 @node Basic concepts
1438 @section Basic concepts
1439
1440 In terms of languages features, Java is mostly a subset
1441 of C++. Java has a few important extensions, plus a powerful standard
1442 class library, but on the whole that does not change the basic similarity.
1443 Java is a hybrid object-oriented language, with a few native types,
1444 in addition to class types. It is class-based, where a class may have
1445 static as well as per-object fields, and static as well as instance methods.
1446 Non-static methods may be virtual, and may be overloaded. Overloading is
1447 resolved at compile time by matching the actual argument types against
1448 the parameter types. Virtual methods are implemented using indirect calls
1449 through a dispatch table (virtual function table). Objects are
1450 allocated on the heap, and initialized using a constructor method.
1451 Classes are organized in a package hierarchy.
1452
1453 All of the listed attributes are also true of C++, though C++ has
1454 extra features (for example in C++ objects may be allocated not just
1455 on the heap, but also statically or in a local stack frame). Because
1456 @command{gcj} uses the same compiler technology as G++ (the GNU
1457 C++ compiler), it is possible to make the intersection of the two
1458 languages use the same ABI (object representation and calling
1459 conventions). The key idea in CNI is that Java objects are C++
1460 objects, and all Java classes are C++ classes (but not the other way
1461 around). So the most important task in integrating Java and C++ is to
1462 remove gratuitous incompatibilities.
1463
1464 You write CNI code as a regular C++ source file. (You do have to use
1465 a Java/CNI-aware C++ compiler, specifically a recent version of G++.)
1466
1467 @noindent A CNI C++ source file must have:
1468
1469 @example
1470 #include <gcj/cni.h>
1471 @end example
1472
1473 @noindent and then must include one header file for each Java class it uses, e.g.:
1474
1475 @example
1476 #include <java/lang/Character.h>
1477 #include <java/util/Date.h>
1478 #include <java/lang/IndexOutOfBoundsException.h>
1479 @end example
1480
1481 @noindent These header files are automatically generated by @code{gcjh}.
1482
1483
1484 CNI provides some functions and macros to make using Java objects and
1485 primitive types from C++ easier. In general, these CNI functions and
1486 macros start with the @code{Jv} prefix, for example the function
1487 @code{JvNewObjectArray}. This convention is used to avoid conflicts
1488 with other libraries. Internal functions in CNI start with the prefix
1489 @code{_Jv_}. You should not call these; if you find a need to, let us
1490 know and we will try to come up with an alternate solution.
1491
1492
1493 @subsection Limitations
1494
1495 Whilst a Java class is just a C++ class that doesn't mean that you are
1496 freed from the shackles of Java, a @acronym{CNI} C++ class must adhere to the
1497 rules of the Java programming language.
1498
1499 For example: it is not possible to declare a method in a CNI class
1500 that will take a C string (@code{char*}) as an argument, or to declare a
1501 member variable of some non-Java datatype.
1502
1503
1504 @node Packages
1505 @section Packages
1506
1507 The only global names in Java are class names, and packages. A
1508 @dfn{package} can contain zero or more classes, and also zero or more
1509 sub-packages. Every class belongs to either an unnamed package or a
1510 package that has a hierarchical and globally unique name.
1511
1512 A Java package is mapped to a C++ @dfn{namespace}. The Java class
1513 @code{java.lang.String} is in the package @code{java.lang}, which is a
1514 sub-package of @code{java}. The C++ equivalent is the class
1515 @code{java::lang::String}, which is in the namespace @code{java::lang}
1516 which is in the namespace @code{java}.
1517
1518 @noindent Here is how you could express this:
1519
1520 @example
1521 (// @r{Declare the class(es), possibly in a header file:}
1522 namespace java @{
1523 namespace lang @{
1524 class Object;
1525 class String;
1526 ...
1527 @}
1528 @}
1529
1530 class java::lang::String : public java::lang::Object
1531 @{
1532 ...
1533 @};
1534 @end example
1535
1536 @noindent The @code{gcjh} tool automatically generates the necessary namespace
1537 declarations.
1538
1539
1540 @subsection Leaving out package names
1541
1542 Always using the fully-qualified name of a java class can be
1543 tiresomely verbose. Using the full qualified name also ties the code
1544 to a single package making code changes necessary should the class
1545 move from one package to another. The Java @code{package} declaration
1546 specifies that the following class declarations are in the named
1547 package, without having to explicitly name the full package
1548 qualifiers. The @code{package} declaration can be
1549 followed by zero or more @code{import} declarations, which
1550 allows either a single class or all the classes in a package to be
1551 named by a simple identifier. C++ provides something similar with the
1552 @code{using} declaration and directive.
1553
1554 @noindent In Java:
1555
1556 @example
1557 import @var{package-name}.@var{class-name};
1558 @end example
1559
1560 @noindent allows the program text to refer to @var{class-name} as a shorthand for
1561 the fully qualified name: @code{@var{package-name}.@var{class-name}}.
1562
1563
1564 @noindent To achieve the same effect C++, you have to do this:
1565
1566 @example
1567 using @var{package-name}::@var{class-name};
1568 @end example
1569
1570
1571 @noindent Java can also cause imports on demand, like this:
1572
1573 @example
1574 import @var{package-name}.*;
1575 @end example
1576
1577 @noindent Doing this allows any class from the package @var{package-name} to be
1578 referred to only by its class-name within the program text.
1579
1580
1581 @noindent The same effect can be achieved in C++ like this:
1582
1583 @example
1584 using namespace @var{package-name};
1585 @end example
1586
1587
1588 @node Primitive types
1589 @section Primitive types
1590
1591 Java provides 8 @dfn{primitives} types which represent integers, floats,
1592 characters and booleans (and also the void type). C++ has its own
1593 very similar concrete types. Such types in C++ however are not always
1594 implemented in the same way (an int might be 16, 32 or 64 bits for example)
1595 so CNI provides a special C++ type for each primitive Java type:
1596
1597 @multitable @columnfractions .20 .25 .60
1598 @item @strong{Java type} @tab @strong{C/C++ typename} @tab @strong{Description}
1599 @item @code{char} @tab @code{jchar} @tab 16 bit Unicode character
1600 @item @code{boolean} @tab @code{jboolean} @tab logical (true or false) values
1601 @item @code{byte} @tab @code{jbyte} @tab 8-bit signed integer
1602 @item @code{short} @tab @code{jshort} @tab 16 bit signed integer
1603 @item @code{int} @tab @code{jint} @tab 32 bit signed integer
1604 @item @code{long} @tab @code{jlong} @tab 64 bit signed integer
1605 @item @code{float} @tab @code{jfloat} @tab 32 bit IEEE floating point number
1606 @item @code{double} @tab @code{jdouble} @tab 64 bit IEEE floating point number
1607 @item @code{void} @tab @code{void} @tab no value
1608 @end multitable
1609
1610 When referring to a Java type You should always use these C++ typenames (e.g.: @code{jint})
1611 to avoid disappointment.
1612
1613
1614 @subsection Reference types associated with primitive types
1615
1616 In Java each primitive type has an associated reference type,
1617 e.g.: @code{boolean} has an associated @code{java.lang.Boolean} class.
1618 In order to make working with such classes easier GCJ provides the macro
1619 @code{JvPrimClass}:
1620
1621 @deffn macro JvPrimClass type
1622 Return a pointer to the @code{Class} object corresponding to the type supplied.
1623
1624 @example
1625 JvPrimClass(void) @result{} java.lang.Void.TYPE
1626 @end example
1627
1628 @end deffn
1629
1630
1631 @node Interfaces
1632 @section Interfaces
1633
1634 A Java class can @dfn{implement} zero or more
1635 @dfn{interfaces}, in addition to inheriting from
1636 a single base class.
1637
1638 @acronym{CNI} allows CNI code to implement methods of interfaces.
1639 You can also call methods through interface references, with some
1640 limitations.
1641
1642 @acronym{CNI} doesn't understand interface inheritance at all yet. So,
1643 you can only call an interface method when the declared type of the
1644 field being called matches the interface which declares that
1645 method. The workaround is to cast the interface reference to the right
1646 superinterface.
1647
1648 For example if you have:
1649
1650 @example
1651 interface A
1652 @{
1653 void a();
1654 @}
1655
1656 interface B extends A
1657 @{
1658 void b();
1659 @}
1660 @end example
1661
1662 and declare a variable of type @code{B} in C++, you can't call
1663 @code{a()} unless you cast it to an @code{A} first.
1664
1665 @node Objects and Classes
1666 @section Objects and Classes
1667
1668 @subsection Classes
1669
1670 All Java classes are derived from @code{java.lang.Object}. C++ does
1671 not have a unique root class, but we use the C++ class
1672 @code{java::lang::Object} as the C++ version of the
1673 @code{java.lang.Object} Java class. All other Java classes are mapped
1674 into corresponding C++ classes derived from @code{java::lang::Object}.
1675
1676 Interface inheritance (the @code{implements} keyword) is currently not
1677 reflected in the C++ mapping.
1678
1679
1680 @subsection Object fields
1681
1682 Each object contains an object header, followed by the instance fields
1683 of the class, in order. The object header consists of a single
1684 pointer to a dispatch or virtual function table. (There may be extra
1685 fields @emph{in front of} the object, for example for memory
1686 management, but this is invisible to the application, and the
1687 reference to the object points to the dispatch table pointer.)
1688
1689 The fields are laid out in the same order, alignment, and size as in
1690 C++. Specifically, 8-bit and 16-bit native types (@code{byte},
1691 @code{short}, @code{char}, and @code{boolean}) are @emph{not} widened
1692 to 32 bits. Note that the Java VM does extend 8-bit and 16-bit types
1693 to 32 bits when on the VM stack or temporary registers.
1694
1695 If you include the @code{gcjh}-generated header for a
1696 class, you can access fields of Java classes in the @emph{natural}
1697 way. For example, given the following Java class:
1698
1699 @example
1700 public class Int
1701 @{
1702 public int i;
1703 public Int (int i) @{ this.i = i; @}
1704 public static Int zero = new Int(0);
1705 @}
1706 @end example
1707
1708 you can write:
1709
1710 @example
1711 #include <gcj/cni.h>;
1712 #include <Int>;
1713
1714 Int*
1715 mult (Int *p, jint k)
1716 @{
1717 if (k == 0)
1718 return Int::zero; // @r{Static member access.}
1719 return new Int(p->i * k);
1720 @}
1721 @end example
1722
1723
1724 @subsection Access specifiers
1725
1726 CNI does not strictly enforce the Java access
1727 specifiers, because Java permissions cannot be directly mapped
1728 into C++ permission. Private Java fields and methods are mapped
1729 to private C++ fields and methods, but other fields and methods
1730 are mapped to public fields and methods.
1731
1732
1733
1734 @node Class Initialization
1735 @section Class Initialization
1736
1737 Java requires that each class be automatically initialized at the time
1738 of the first active use. Initializing a class involves
1739 initializing the static fields, running code in class initializer
1740 methods, and initializing base classes. There may also be
1741 some implementation specific actions, such as allocating
1742 @code{String} objects corresponding to string literals in
1743 the code.
1744
1745 The GCJ compiler inserts calls to @code{JvInitClass} at appropriate
1746 places to ensure that a class is initialized when required. The C++
1747 compiler does not insert these calls automatically---it is the
1748 programmer's responsibility to make sure classes are initialized.
1749 However, this is fairly painless because of the conventions assumed by
1750 the Java system.
1751
1752 First, @code{libgcj} will make sure a class is initialized before an
1753 instance of that object is created. This is one of the
1754 responsibilities of the @code{new} operation. This is taken care of
1755 both in Java code, and in C++ code. When G++ sees a @code{new} of a
1756 Java class, it will call a routine in @code{libgcj} to allocate the
1757 object, and that routine will take care of initializing the class.
1758 Note however that this does not happen for Java arrays; you must
1759 allocate those using the appropriate CNI function. It follows that
1760 you can access an instance field, or call an instance (non-static)
1761 method and be safe in the knowledge that the class and all of its base
1762 classes have been initialized.
1763
1764 Invoking a static method is also safe. This is because the
1765 Java compiler adds code to the start of a static method to make sure
1766 the class is initialized. However, the C++ compiler does not
1767 add this extra code. Hence, if you write a native static method
1768 using CNI, you are responsible for calling @code{JvInitClass}
1769 before doing anything else in the method (unless you are sure
1770 it is safe to leave it out).
1771
1772 Accessing a static field also requires the class of the
1773 field to be initialized. The Java compiler will generate code
1774 to call @code{JvInitClass} before getting or setting the field.
1775 However, the C++ compiler will not generate this extra code,
1776 so it is your responsibility to make sure the class is
1777 initialized before you access a static field from C++.
1778
1779
1780 @node Object allocation
1781 @section Object allocation
1782
1783 New Java objects are allocated using a
1784 @dfn{class instance creation expression}, e.g.:
1785
1786 @example
1787 new @var{Type} ( ... )
1788 @end example
1789
1790 The same syntax is used in C++. The main difference is that
1791 C++ objects have to be explicitly deleted; in Java they are
1792 automatically deleted by the garbage collector.
1793 Using @acronym{CNI}, you can allocate a new Java object
1794 using standard C++ syntax and the C++ compiler will allocate
1795 memory from the garbage collector. If you have overloaded
1796 constructors, the compiler will choose the correct one
1797 using standard C++ overload resolution rules.
1798
1799 @noindent For example:
1800
1801 @example
1802 java::util::Hashtable *ht = new java::util::Hashtable(120);
1803 @end example
1804
1805
1806 @node Memory allocation
1807 @section Memory allocation
1808
1809 When allocating memory in @acronym{CNI} methods it is best to handle
1810 out-of-memory conditions by throwing a Java exception. These
1811 functions are provided for that purpose:
1812
1813 @deftypefun void* JvMalloc (jsize @var{size})
1814 Calls malloc. Throws @code{java.lang.OutOfMemoryError} if allocation
1815 fails.
1816 @end deftypefun
1817
1818 @deftypefun void* JvRealloc (void* @var{ptr}, jsize @var{size})
1819 Calls realloc. Throws @code{java.lang.OutOfMemoryError} if
1820 reallocation fails.
1821 @end deftypefun
1822
1823 @deftypefun void JvFree (void* @var{ptr})
1824 Calls free.
1825 @end deftypefun
1826
1827 @node Arrays
1828 @section Arrays
1829
1830 While in many ways Java is similar to C and C++, it is quite different
1831 in its treatment of arrays. C arrays are based on the idea of pointer
1832 arithmetic, which would be incompatible with Java's security
1833 requirements. Java arrays are true objects (array types inherit from
1834 @code{java.lang.Object}). An array-valued variable is one that
1835 contains a reference (pointer) to an array object.
1836
1837 Referencing a Java array in C++ code is done using the
1838 @code{JArray} template, which as defined as follows:
1839
1840 @example
1841 class __JArray : public java::lang::Object
1842 @{
1843 public:
1844 int length;
1845 @};
1846
1847 template<class T>
1848 class JArray : public __JArray
1849 @{
1850 T data[0];
1851 public:
1852 T& operator[](jint i) @{ return data[i]; @}
1853 @};
1854 @end example
1855
1856
1857 There are a number of @code{typedef}s which correspond to @code{typedef}s
1858 from the @acronym{JNI}. Each is the type of an array holding objects
1859 of the relevant type:
1860
1861 @example
1862 typedef __JArray *jarray;
1863 typedef JArray<jobject> *jobjectArray;
1864 typedef JArray<jboolean> *jbooleanArray;
1865 typedef JArray<jbyte> *jbyteArray;
1866 typedef JArray<jchar> *jcharArray;
1867 typedef JArray<jshort> *jshortArray;
1868 typedef JArray<jint> *jintArray;
1869 typedef JArray<jlong> *jlongArray;
1870 typedef JArray<jfloat> *jfloatArray;
1871 typedef JArray<jdouble> *jdoubleArray;
1872 @end example
1873
1874
1875 @deftypemethod {template<class T>} T* elements (JArray<T> @var{array})
1876 This template function can be used to get a pointer to the elements of
1877 the @code{array}. For instance, you can fetch a pointer to the
1878 integers that make up an @code{int[]} like so:
1879
1880 @example
1881 extern jintArray foo;
1882 jint *intp = elements (foo);
1883 @end example
1884
1885 The name of this function may change in the future.
1886 @end deftypemethod
1887
1888
1889 @deftypefun jobjectArray JvNewObjectArray (jsize @var{length}, jclass @var{klass}, jobject @var{init})
1890 Here @code{klass} is the type of elements of the array and
1891 @code{init} is the initial value put into every slot in the array.
1892 @end deftypefun
1893
1894
1895 @subsection Creating arrays
1896
1897 For each primitive type there is a function which can be used to
1898 create a new array of that type. The name of the function is of the
1899 form:
1900
1901 @example
1902 JvNew@var{Type}Array
1903 @end example
1904
1905 @noindent For example:
1906
1907 @example
1908 JvNewBooleanArray
1909 @end example
1910
1911 @noindent can be used to create an array of Java primitive boolean types.
1912
1913 @noindent The following function definition is the template for all such functions:
1914
1915 @deftypefun jbooleanArray JvNewBooleanArray (jint @var{length})
1916 Create's an array @var{length} indices long.
1917 @end deftypefun
1918
1919 @deftypefun jsize JvGetArrayLength (jarray @var{array})
1920 Returns the length of the @var{array}.
1921 @end deftypefun
1922
1923
1924 @node Methods
1925 @section Methods
1926
1927 Java methods are mapped directly into C++ methods.
1928 The header files generated by @code{gcjh}
1929 include the appropriate method definitions.
1930 Basically, the generated methods have the same names and
1931 @emph{corresponding} types as the Java methods,
1932 and are called in the natural manner.
1933
1934 @subsection Overloading
1935
1936 Both Java and C++ provide method overloading, where multiple
1937 methods in a class have the same name, and the correct one is chosen
1938 (at compile time) depending on the argument types.
1939 The rules for choosing the correct method are (as expected) more complicated
1940 in C++ than in Java, but given a set of overloaded methods
1941 generated by @code{gcjh} the C++ compiler will choose
1942 the expected one.
1943
1944 Common assemblers and linkers are not aware of C++ overloading,
1945 so the standard implementation strategy is to encode the
1946 parameter types of a method into its assembly-level name.
1947 This encoding is called @dfn{mangling},
1948 and the encoded name is the @dfn{mangled name}.
1949 The same mechanism is used to implement Java overloading.
1950 For C++/Java interoperability, it is important that both the Java
1951 and C++ compilers use the @emph{same} encoding scheme.
1952
1953 @subsection Static methods
1954
1955 Static Java methods are invoked in @acronym{CNI} using the standard
1956 C++ syntax, using the @code{::} operator rather
1957 than the @code{.} operator.
1958
1959 @noindent For example:
1960
1961 @example
1962 jint i = java::lang::Math::round((jfloat) 2.3);
1963 @end example
1964
1965 @noindent C++ method definition syntax is used to define a static native method.
1966 For example:
1967
1968 @example
1969 #include <java/lang/Integer>
1970 java::lang::Integer*
1971 java::lang::Integer::getInteger(jstring str)
1972 @{
1973 ...
1974 @}
1975 @end example
1976
1977
1978 @subsection Object Constructors
1979
1980 Constructors are called implicitly as part of object allocation
1981 using the @code{new} operator.
1982
1983 @noindent For example:
1984
1985 @example
1986 java::lang::Integer *x = new java::lang::Integer(234);
1987 @end example
1988
1989 Java does not allow a constructor to be a native method.
1990 This limitation can be coded round however because a constructor
1991 can @emph{call} a native method.
1992
1993
1994 @subsection Instance methods
1995
1996 Calling a Java instance method from a C++ @acronym{CNI} method is done
1997 using the standard C++ syntax, e.g.:
1998
1999 @example
2000 // @r{First create the Java object.}
2001 java::lang::Integer *x = new java::lang::Integer(234);
2002 // @r{Now call a method.}
2003 jint prim_value = x->intValue();
2004 if (x->longValue == 0)
2005 ...
2006 @end example
2007
2008 @noindent Defining a Java native instance method is also done the natural way:
2009
2010 @example
2011 #include <java/lang/Integer.h>
2012
2013 jdouble
2014 java::lang:Integer::doubleValue()
2015 @{
2016 return (jdouble) value;
2017 @}
2018 @end example
2019
2020
2021 @subsection Interface methods
2022
2023 In Java you can call a method using an interface reference. This is
2024 supported, but not completely. @xref{Interfaces}.
2025
2026
2027
2028
2029 @node Strings
2030 @section Strings
2031
2032 @acronym{CNI} provides a number of utility functions for
2033 working with Java Java @code{String} objects.
2034 The names and interfaces are analogous to those of @acronym{JNI}.
2035
2036
2037 @deftypefun jstring JvNewString (const char* @var{chars}, jsize @var{len})
2038 Returns a Java @code{String} object with characters from the C string
2039 @var{chars} up to the index @var{len} in that array.
2040 @end deftypefun
2041
2042 @deftypefun jstring JvNewStringLatin1 (const char* @var{bytes}, jsize @var{len})
2043 Returns a Java @code{String} made up of @var{len} bytes from @var{bytes}.
2044 @end deftypefun
2045
2046
2047 @deftypefun jstring JvNewStringLatin1 (const char* @var{bytes})
2048 As above but the length of the @code{String} is @code{strlen(@var{bytes})}.
2049 @end deftypefun
2050
2051 @deftypefun jstring JvNewStringUTF (const char* @var{bytes})
2052 Returns a @code{String} which is made up of the UTF encoded characters
2053 present in the C string @var{bytes}.
2054 @end deftypefun
2055
2056 @deftypefun jchar* JvGetStringChars (jstring @var{str})
2057 Returns a pointer to an array of characters making up the @code{String} @var{str}.
2058 @end deftypefun
2059
2060 @deftypefun int JvGetStringUTFLength (jstring @var{str})
2061 Returns the number of bytes required to encode the contents of the
2062 @code{String} @var{str} in UTF-8.
2063 @end deftypefun
2064
2065 @deftypefun jsize JvGetStringUTFRegion (jstring @var{str}, jsize @var{start}, jsize @var{len}, char* @var{buf})
2066 Puts the UTF-8 encoding of a region of the @code{String} @var{str} into
2067 the buffer @code{buf}. The region to fetch is marked by @var{start} and @var{len}.
2068
2069 Note that @var{buf} is a buffer, not a C string. It is @emph{not}
2070 null terminated.
2071 @end deftypefun
2072
2073
2074 @node Mixing with C++
2075 @section Interoperating with C/C++
2076
2077 Because @acronym{CNI} is designed to represent Java classes and methods it
2078 cannot be mixed readily with C/C++ types.
2079
2080 One important restriction is that Java classes cannot have non-Java
2081 type instance or static variables and cannot have methods which take
2082 non-Java types as arguments or return non-Java types.
2083
2084 @noindent None of the following is possible with CNI:
2085
2086 @example
2087
2088 class ::MyClass : public java::lang::Object
2089 @{
2090 char* variable; // @r{char* is not a valid Java type.}
2091 @}
2092
2093
2094 uint
2095 ::SomeClass::someMethod (char *arg)
2096 @{
2097 .
2098 .
2099 .
2100 @} // @r{@code{uint} is not a valid Java type, neither is @code{char*}}
2101 @end example
2102
2103 @noindent Of course, it is ok to use C/C++ types within the scope of a method:
2104
2105
2106 @example
2107 jint
2108 ::SomeClass::otherMethod (jstring str)
2109 @{
2110 char *arg = ...
2111 .
2112 .
2113 .
2114 @}
2115 @end example
2116
2117 @subsection RawData
2118
2119 The above restriction can be problematic, so @acronym{CNI} includes the
2120 @code{gnu.gcj.RawData} class. The @code{RawData} class is a
2121 @dfn{non-scanned reference} type. In other words variables declared
2122 of type @code{RawData} can contain any data and are not checked by the
2123 compiler or memory manager in any way.
2124
2125 This means that you can put C/C++ data structures (including classes)
2126 in your @acronym{CNI} classes, as long as you use the appropriate cast.
2127
2128 @noindent Here are some examples:
2129
2130 @example
2131
2132 class ::MyClass : public java::lang::Object
2133 @{
2134 gnu.gcj.RawData string;
2135
2136 MyClass ();
2137 gnu.gcj.RawData getText ();
2138 void printText ();
2139 @}
2140
2141 ::MyClass::MyClass ()
2142 @{
2143 char* text = ...
2144 string = text;
2145 @}
2146
2147 gnu.gcj.RawData
2148 ::MyClass::getText ()
2149 @{
2150 return string;
2151 @}
2152
2153 void
2154 ::MyClass::printText ()
2155 @{
2156 printf("%s\n", (char*) string);
2157 @}
2158 @end example
2159
2160
2161 @subsection RawDataManaged
2162
2163 @code{gnu.gcj.RawDataManaged} is another type used to indicate special data used
2164 by native code. Unlike the @code{RawData} type, fields declared as
2165 @code{RawDataManaged} will be "marked" by the memory manager and
2166 considered for garbage collection.
2167
2168 Native data which is allocated using CNI's @code{JvAllocBytes()}
2169 function and stored in a @code{RawDataManaged} will be automatically
2170 freed when the Java object it is associated with becomes unreachable.
2171
2172 @subsection Native memory allocation
2173
2174 @deftypefun void* JvAllocBytes (jsize @var{size})
2175 Allocates @var{size} bytes from the heap. The memory returned is zeroed.
2176 This memory is not scanned for pointers by the garbage collector, but will
2177 be freed if no references to it are discovered.
2178
2179 This function can be useful if you need to associate some native data with a
2180 Java object. Using a CNI's special @code{RawDataManaged} type, native data
2181 allocated with @code{JvAllocBytes} will be automatically freed when the Java
2182 object itself becomes unreachable.
2183 @end deftypefun
2184
2185 @subsection Posix signals
2186
2187 On Posix based systems the @code{libgcj} library uses several signals
2188 internally. @acronym{CNI} code should not attempt to use the same
2189 signals as doing so may cause @code{libgcj} and/or the @acronym{CNI}
2190 code to fail.
2191
2192 SIGSEGV is used on many systems to generate
2193 @code{NullPointerExceptions}. SIGCHLD is used internally by
2194 @code{Runtime.exec()}. Several other signals (that vary from platform to
2195 platform) can be used by the memory manager and by
2196 @code{Thread.interrupt()}.
2197
2198 @node Exception Handling
2199 @section Exception Handling
2200
2201 While C++ and Java share a common exception handling framework,
2202 things are not yet perfectly integrated. The main issue is that the
2203 run-time type information facilities of the two
2204 languages are not integrated.
2205
2206 Still, things work fairly well. You can throw a Java exception from
2207 C++ using the ordinary @code{throw} construct, and this
2208 exception can be caught by Java code. Similarly, you can catch an
2209 exception thrown from Java using the C++ @code{catch}
2210 construct.
2211
2212 @noindent Here is an example:
2213
2214 @example
2215 if (i >= count)
2216 throw new java::lang::IndexOutOfBoundsException();
2217 @end example
2218
2219 Normally, G++ will automatically detect when you are writing C++
2220 code that uses Java exceptions, and handle them appropriately.
2221 However, if C++ code only needs to execute destructors when Java
2222 exceptions are thrown through it, GCC will guess incorrectly. Sample
2223 problematic code:
2224
2225 @example
2226 struct S @{ ~S(); @};
2227
2228 extern void bar(); // @r{Is implemented in Java and may throw exceptions.}
2229
2230 void foo()
2231 @{
2232 S s;
2233 bar();
2234 @}
2235 @end example
2236
2237 The usual effect of an incorrect guess is a link failure, complaining of
2238 a missing routine called @code{__gxx_personality_v0}.
2239
2240 You can inform the compiler that Java exceptions are to be used in a
2241 translation unit, irrespective of what it might think, by writing
2242 @code{#pragma GCC java_exceptions} at the head of the
2243 file. This @code{#pragma} must appear before any
2244 functions that throw or catch exceptions, or run destructors when
2245 exceptions are thrown through them.
2246
2247 @node Synchronization
2248 @section Synchronization
2249
2250 Each Java object has an implicit monitor.
2251 The Java VM uses the instruction @code{monitorenter} to acquire
2252 and lock a monitor, and @code{monitorexit} to release it.
2253
2254 The corresponding CNI macros are @code{JvMonitorEnter} and
2255 @code{JvMonitorExit} (JNI has similar methods @code{MonitorEnter}
2256 and @code{MonitorExit}).
2257
2258
2259 The Java source language does not provide direct access to these primitives.
2260 Instead, there is a @code{synchronized} statement that does an
2261 implicit @code{monitorenter} before entry to the block,
2262 and does a @code{monitorexit} on exit from the block.
2263 Note that the lock has to be released even when the block is abnormally
2264 terminated by an exception, which means there is an implicit
2265 @code{try finally} surrounding synchronization locks.
2266
2267 From C++, it makes sense to use a destructor to release a lock.
2268 @acronym{CNI} defines the following utility class:
2269
2270 @example
2271 class JvSynchronize() @{
2272 jobject obj;
2273 JvSynchronize(jobject o) @{ obj = o; JvMonitorEnter(o); @}
2274 ~JvSynchronize() @{ JvMonitorExit(obj); @}
2275 @};
2276 @end example
2277
2278 So this Java code:
2279
2280 @example
2281 synchronized (OBJ)
2282 @{
2283 CODE
2284 @}
2285 @end example
2286
2287 @noindent might become this C++ code:
2288
2289 @example
2290 @{
2291 JvSynchronize dummy (OBJ);
2292 CODE;
2293 @}
2294 @end example
2295
2296 Java also has methods with the @code{synchronized} attribute.
2297 This is equivalent to wrapping the entire method body in a
2298 @code{synchronized} statement.
2299 (Alternatively, an implementation could require the caller to do
2300 the synchronization. This is not practical for a compiler, because
2301 each virtual method call would have to test at run-time if
2302 synchronization is needed.) Since in @command{gcj}
2303 the @code{synchronized} attribute is handled by the
2304 method implementation, it is up to the programmer
2305 of a synchronized native method to handle the synchronization
2306 (in the C++ implementation of the method).
2307 In other words, you need to manually add @code{JvSynchronize}
2308 in a @code{native synchronized} method.
2309
2310 @node Invocation
2311 @section Invocation
2312
2313 CNI permits C++ applications to make calls into Java classes, in addition to
2314 allowing Java code to call into C++. Several functions, known as the
2315 @dfn{invocation API}, are provided to support this.
2316
2317 @deftypefun jint JvCreateJavaVM (JvVMInitArgs* @var{vm_args})
2318
2319 Initializes the Java runtime. This function performs essential initialization
2320 of the threads interface, garbage collector, exception handling and other key
2321 aspects of the runtime. It must be called once by an application with
2322 a non-Java @code{main()} function, before any other Java or CNI calls are made.
2323 It is safe, but not recommended, to call @code{JvCreateJavaVM()} more than
2324 once provided it is only called from a single thread.
2325 The @var{vmargs} parameter can be used to specify initialization parameters
2326 for the Java runtime. It may be @code{NULL}.
2327
2328 JvVMInitArgs represents a list of virtual machine initialization
2329 arguments. @code{JvCreateJavaVM()} ignores the version field.
2330
2331 @example
2332 typedef struct JvVMOption
2333 @{
2334 // a VM initialization option
2335 char* optionString;
2336 // extra information associated with this option
2337 void* extraInfo;
2338 @} JvVMOption;
2339
2340 typedef struct JvVMInitArgs
2341 @{
2342 // for compatibility with JavaVMInitArgs
2343 jint version;
2344
2345 // number of VM initialization options
2346 jint nOptions;
2347
2348 // an array of VM initialization options
2349 JvVMOption* options;
2350
2351 // true if the option parser should ignore unrecognized options
2352 jboolean ignoreUnrecognized;
2353 @} JvVMInitArgs;
2354 @end example
2355
2356 @code{JvCreateJavaVM()} returns @code{0} upon success, or @code{-1} if
2357 the runtime is already initialized.
2358
2359 @emph{Note:} In GCJ 3.1, the @code{vm_args} parameter is ignored. It
2360 is recognized and used as of release 4.0.
2361 @end deftypefun
2362
2363 @deftypefun java::lang::Thread* JvAttachCurrentThread (jstring @var{name}, java::lang::ThreadGroup* @var{group})
2364 Registers an existing thread with the Java runtime. This must be called once
2365 from each thread, before that thread makes any other Java or CNI calls. It
2366 must be called after @code{JvCreateJavaVM}.
2367 @var{name} specifies a name for the thread. It may be @code{NULL}, in which
2368 case a name will be generated.
2369 @var{group} is the ThreadGroup in which this thread will be a member. If it
2370 is @code{NULL}, the thread will be a member of the main thread group.
2371 The return value is the Java @code{Thread} object that represents the thread.
2372 It is safe to call @code{JvAttachCurrentThread()} more than once from the same
2373 thread. If the thread is already attached, the call is ignored and the current
2374 thread object is returned.
2375 @end deftypefun
2376
2377 @deftypefun jint JvDetachCurrentThread ()
2378 Unregisters a thread from the Java runtime. This should be called by threads
2379 that were attached using @code{JvAttachCurrentThread()}, after they have
2380 finished making calls to Java code. This ensures that any resources associated
2381 with the thread become eligible for garbage collection.
2382 This function returns @code{0} upon success, or @code{-1} if the current thread
2383 is not attached.
2384 @end deftypefun
2385
2386 @subsection Handling uncaught exceptions
2387
2388 If an exception is thrown from Java code called using the invocation API, and
2389 no handler for the exception can be found, the runtime will abort the
2390 application. In order to make the application more robust, it is recommended
2391 that code which uses the invocation API be wrapped by a top-level try/catch
2392 block that catches all Java exceptions.
2393
2394 @subsection Example
2395
2396 The following code demonstrates the use of the invocation API. In this
2397 example, the C++ application initializes the Java runtime and attaches
2398 itself. The @code{java.lang.System} class is initialized in order to
2399 access its @code{out} field, and a Java string is printed. Finally, the thread
2400 is detached from the runtime once it has finished making Java calls. Everything
2401 is wrapped with a try/catch block to provide a default handler for any uncaught
2402 exceptions.
2403
2404 The example can be compiled with @command{c++ test.cc -lgcj}.
2405
2406 @example
2407 // test.cc
2408 #include <gcj/cni.h>
2409 #include <java/lang/System.h>
2410 #include <java/io/PrintStream.h>
2411 #include <java/lang/Throwable.h>
2412
2413 int main(int argc, char *argv)
2414 @{
2415 using namespace java::lang;
2416
2417 try
2418 @{
2419 JvCreateJavaVM(NULL);
2420 JvAttachCurrentThread(NULL, NULL);
2421
2422 String *message = JvNewStringLatin1("Hello from C++");
2423 JvInitClass(&System::class$);
2424 System::out->println(message);
2425
2426 JvDetachCurrentThread();
2427 @}
2428 catch (Throwable *t)
2429 @{
2430 System::err->println(JvNewStringLatin1("Unhandled Java exception:"));
2431 t->printStackTrace();
2432 @}
2433 @}
2434 @end example
2435
2436 @node Reflection
2437 @section Reflection
2438
2439 Reflection is possible with CNI code, it functions similarly to how it
2440 functions with JNI@.
2441
2442 @c clean this up... I mean, what are the types jfieldID and jmethodID in JNI?
2443 The types @code{jfieldID} and @code{jmethodID}
2444 are as in JNI@.
2445
2446 @noindent The functions:
2447
2448 @itemize
2449 @item @code{JvFromReflectedField},
2450 @item @code{JvFromReflectedMethod},
2451 @item @code{JvToReflectedField}
2452 @item @code{JvToFromReflectedMethod}
2453 @end itemize
2454
2455 @noindent will be added shortly, as will other functions corresponding to JNI@.
2456
2457
2458 @node System properties
2459 @chapter System properties
2460
2461 The runtime behavior of the @code{libgcj} library can be modified by setting
2462 certain system properties. These properties can be compiled into the program
2463 using the @code{-D@var{name}[=@var{value}]} option to @command{gcj} or by
2464 setting them explicitly in the program by calling the
2465 @code{java.lang.System.setProperty()} method. Some system properties are only
2466 used for informational purposes (like giving a version number or a user name).
2467 A program can inspect the current value of a property by calling the
2468 @code{java.lang.System.getProperty()} method.
2469
2470 @menu
2471 * Standard Properties:: Standard properties supported by @code{libgcj}
2472 * GNU Classpath Properties:: Properties found in Classpath based libraries
2473 * libgcj Runtime Properties:: Properties specific to @code{libgcj}
2474 @end menu
2475
2476 @node Standard Properties
2477 @section Standard Properties
2478
2479 The following properties are normally found in all implementations of the core
2480 libraries for the Java language.
2481
2482 @table @gcctabopt
2483
2484 @item java.version
2485 The @code{libgcj} version number.
2486
2487 @item java.vendor
2488 Set to @samp{The Free Software Foundation, Inc.}
2489
2490 @item java.vendor.url
2491 Set to @uref{http://gcc.gnu.org/java/}.
2492
2493 @item java.home
2494 The directory where @code{gcj} was installed. Taken from the @code{--prefix}
2495 option given to @command{configure}.
2496
2497 @item java.class.version
2498 The class format version number supported by the libgcj byte code interpreter.
2499 (Currently @samp{46.0})
2500
2501 @item java.vm.specification.version
2502 The Virtual Machine Specification version implemented by @code{libgcj}.
2503 (Currently @samp{1.0})
2504
2505 @item java.vm.specification.vendor
2506 The name of the Virtual Machine specification designer.
2507
2508 @item java.vm.specification.name
2509 The name of the Virtual Machine specification
2510 (Set to @samp{Java Virtual Machine Specification}).
2511
2512 @item java.vm.version
2513 The @command{gcj} version number.
2514
2515 @item java.vm.vendor
2516 Set to @samp{The Free Software Foundation, Inc.}
2517
2518 @item java.vm.name
2519 Set to @samp{GNU libgcj}.
2520
2521 @item java.specification.version
2522 The Runtime Environment specification version implemented by @code{libgcj}.
2523 (Currently set to @samp{1.3})
2524
2525 @item java.specification.vendor
2526 The Runtime Environment specification designer.
2527
2528 @item java.specification.name
2529 The name of the Runtime Environment specification
2530 (Set to @samp{Java Platform API Specification}).
2531
2532 @item java.class.path
2533 The paths (jar files, zip files and directories) used for finding class files.
2534
2535 @item java.library.path
2536 Directory path used for finding native libraries.
2537
2538 @item java.io.tmpdir
2539 The directory used to put temporary files in.
2540
2541 @item java.compiler
2542 Name of the Just In Time compiler to use by the byte code interpreter.
2543 Currently not used in @code{libgcj}.
2544
2545 @item java.ext.dirs
2546 Directories containing jar files with extra libraries. Will be used when
2547 resolving classes.
2548
2549 @item java.protocol.handler.pkgs
2550 A @samp{|} separated list of package names that is used to find classes that
2551 implement handlers for @code{java.net.URL}.
2552
2553 @item java.rmi.server.codebase
2554 A list of URLs that is used by the @code{java.rmi.server.RMIClassLoader}
2555 to load classes from.
2556
2557 @item jdbc.drivers
2558 A list of class names that will be loaded by the @code{java.sql.DriverManager}
2559 when it starts up.
2560
2561 @item file.separator
2562 The separator used in when directories are included in a filename
2563 (normally @samp{/} or @samp{\} ).
2564
2565 @item file.encoding
2566 The default character encoding used when converting platform native files to
2567 Unicode (usually set to @samp{8859_1}).
2568
2569 @item path.separator
2570 The standard separator used when a string contains multiple paths
2571 (normally @samp{:} or @samp{;}), the string is usually not a valid character
2572 to use in normal directory names.)
2573
2574 @item line.separator
2575 The default line separator used on the platform (normally @samp{\n}, @samp{\r}
2576 or a combination of those two characters).
2577
2578 @item policy.provider
2579 The class name used for the default policy provider returned by
2580 @code{java.security.Policy.getPolicy}.
2581
2582 @item user.name
2583 The name of the user running the program. Can be the full name, the login name
2584 or empty if unknown.
2585
2586 @item user.home
2587 The default directory to put user specific files in.
2588
2589 @item user.dir
2590 The current working directory from which the program was started.
2591
2592 @item user.language
2593 The default language as used by the @code{java.util.Locale} class.
2594
2595 @item user.region
2596 The default region as used by the @code{java.util.Local} class.
2597
2598 @item user.variant
2599 The default variant of the language and region local used.
2600
2601 @item user.timezone
2602 The default timezone as used by the @code{java.util.TimeZone} class.
2603
2604 @item os.name
2605 The operating system/kernel name that the program runs on.
2606
2607 @item os.arch
2608 The hardware that we are running on.
2609
2610 @item os.version
2611 The version number of the operating system/kernel.
2612
2613 @item awt.appletWarning
2614 The string to display when an untrusted applet is displayed.
2615 Returned by @code{java.awt.Window.getWarningString()} when the window is
2616 ``insecure''.
2617
2618 @item awt.toolkit
2619 The class name used for initializing the default @code{java.awt.Toolkit}.
2620 Defaults to @code{gnu.awt.gtk.GtkToolkit}.
2621
2622 @item http.proxyHost
2623 Name of proxy host for http connections.
2624
2625 @item http.proxyPort
2626 Port number to use when a proxy host is in use.
2627
2628 @end table
2629
2630 @node GNU Classpath Properties
2631 @section GNU Classpath Properties
2632
2633 @code{libgcj} is based on the GNU Classpath (Essential Libraries for Java) a
2634 GNU project to create free core class libraries for use with virtual machines
2635 and compilers for the Java language. The following properties are common to
2636 libraries based on GNU Classpath.
2637
2638 @table @gcctabopt
2639
2640 @item gcj.dumpobject
2641 Enables printing serialization debugging by the @code{java.io.ObjectInput} and
2642 @code{java.io.ObjectOutput} classes when set to something else then the empty
2643 string. Only used when running a debug build of the library.
2644
2645 @item gnu.classpath.vm.shortname
2646 This is a succint name of the virtual machine. For @code{libgcj},
2647 this will always be @samp{libgcj}.
2648
2649 @item gnu.classpath.home.url
2650 A base URL used for finding system property files (e.g.,
2651 @file{classpath.security}). By default this is a @samp{file:} URL
2652 pointing to the @file{lib} directory under @samp{java.home}.
2653
2654 @end table
2655
2656 @node libgcj Runtime Properties
2657 @section libgcj Runtime Properties
2658
2659 The following properties are specific to the @code{libgcj} runtime and will
2660 normally not be found in other core libraries for the java language.
2661
2662 @table @gcctabopt
2663
2664 @item java.fullversion
2665 The combination of @code{java.vm.name} and @code{java.vm.version}.
2666
2667 @item java.vm.info
2668 Same as @code{java.fullversion}.
2669
2670 @item impl.prefix
2671 Used by the @code{java.net.DatagramSocket} class when set to something else
2672 then the empty string. When set all newly created @code{DatagramSocket}s will
2673 try to load a class @code{java.net.[impl.prefix]DatagramSocketImpl} instead of
2674 the normal @code{java.net.PlainDatagramSocketImpl}.
2675
2676 @item gnu.gcj.progname
2677 The class or binary name that was used to invoke the program. This will be
2678 the name of the "main" class in the case where the @code{gij} front end is
2679 used, or the program binary name in the case where an application is compiled
2680 to a native binary.
2681
2682 @item gnu.gcj.runtime.NameFinder.use_addr2line
2683 Whether an external process, @command{addr2line}, should be used to determine
2684 line number information when tracing the stack. Setting this to @code{false}
2685 may suppress line numbers when printing stack traces and when using
2686 the java.util.logging infrastructure. However, performance may improve
2687 significantly for applications that print stack traces or make logging calls
2688 frequently.
2689
2690 @item gnu.gcj.runtime.VMClassLoader.library_control
2691 This controls how shared libraries are automatically loaded by the
2692 built-in class loader. If this property is set to @samp{full}, a full
2693 search is done for each requested class. If this property is set to
2694 @samp{cache} (the default), then any failed lookups are cached and not
2695 tried again. If this property is set to @samp{never}, then lookups
2696 are never done. For more information, @xref{Extensions}.
2697
2698 @item gnu.gcj.runtime.endorsed.dirs
2699 This is like the standard @code{java.endorsed.dirs}, property, but
2700 specifies some extra directories which are searched after the standard
2701 endorsed directories. This is primarily useful for telling
2702 @code{libgcj} about additional libraries which are ordinarily
2703 incorporated into the JDK, and which should be loaded by the bootstrap
2704 class loader, but which are not yet part of @code{libgcj} itself for
2705 some reason.
2706
2707 @item gnu.gcj.jit.compiler
2708 @c FIXME we should probably have a whole node on this...
2709 This is the full path to @command{gcj} executable which should be
2710 used to compile classes just-in-time when
2711 @code{ClassLoader.defineClass} is called. If not set, @command{gcj}
2712 will not be invoked by the runtime; this can also be controlled via
2713 @code{Compiler.disable}.
2714
2715 @item gnu.gcj.jit.options
2716 This is a space-separated string of options which should be passed to
2717 @command{gcj} when in JIT mode. If not set, a sensible default is
2718 chosen.
2719
2720 @item gnu.gcj.jit.cachedir
2721 This is the directory where cached shared library files are
2722 stored. If not set, JIT compilation is disabled. This should never
2723 be set to a directory that is writable by any other user.
2724
2725 @item gnu.gcj.precompiled.db.path
2726 This is a sequence of file names, each referring to a file created by
2727 @command{gcj-dbtool}. These files will be used by @code{libgcj} to
2728 find shared libraries corresponding to classes that are loaded from
2729 bytecode. @code{libgcj} often has a built-in default database; it
2730 can be queried using @code{gcj-dbtool -p}.
2731
2732 @end table
2733
2734
2735 @node Resources
2736 @chapter Resources
2737
2738 While writing @command{gcj} and @code{libgcj} we have, of course, relied
2739 heavily on documentation from Sun Microsystems. In particular we have
2740 used The Java Language Specification (both first and second editions),
2741 the Java Class Libraries (volumes one and two), and the Java Virtual
2742 Machine Specification. In addition we've used the online documentation
2743 at @uref{http://java.sun.com/}.
2744
2745 The current @command{gcj} home page is
2746 @uref{http://gcc.gnu.org/java/}.
2747
2748 For more information on gcc, see @uref{http://gcc.gnu.org/}.
2749
2750 Some @code{libgcj} testing is done using the Mauve test suite. This is
2751 a free software Java class library test suite which is being written
2752 because the JCK is not free. See
2753 @uref{http://sources.redhat.com/mauve/} for more information.
2754
2755 @bye