OSDN Git Service

* doc/cpp.texi, doc/cppinternals.texi, doc/gcc.texi: Move contents
[pf3gnuchains/gcc-fork.git] / gcc / java / gcj.texi
1 @\input texinfo @c -*-texinfo-*-
2 @setfilename gcj.info
3 @settitle Guide to GNU gcj
4
5 @c Note: When reading this manual you'll find lots of strange
6 @c circumlocutions like ``compiler for the Java language''.
7 @c This is necessary due to Sun's restrictions on the use of
8 @c the word ``Java'.
9
10 @c When this manual is copyrighted.
11 @set copyrights-gcj 2001
12
13 @c Versions
14 @set version-gcc 3.1
15 @set which-gcj GCC-@value{version-gcc}
16
17 @ifinfo
18 @format
19 @dircategory Programming
20 @direntry
21 * Gcj: (gcj).               Ahead-of-time compiler for the Java language
22 @end direntry
23
24 @dircategory Individual utilities
25 @direntry
26 * gcjh: (gcj)Invoking gcjh.
27                             Generate header files from Java class files
28 * jv-scan: (gcj)Invoking jv-scan.
29                             Print information about Java source files
30 * jcf-dump: (gcj)Invoking jcf-dump.
31                             Print information about Java class files
32 * gij: (gcj)Invoking gij.   GNU interpreter for Java bytecode
33 @end direntry
34 @end format
35
36 Copyright (C) @value{copyrights-gcj} Free Software Foundation, Inc.
37
38 Permission is granted to copy, distribute and/or modify this document
39 under the terms of the GNU Free Documentation License, Version 1.1 or
40 any later version published by the Free Software Foundation; with the
41 Invariant Sections being ``GNU General Public License'', the Front-Cover
42 texts being (a) (see below), and with the Back-Cover Texts being (b)
43 (see below).  A copy of the license is included in the section entitled
44 ``GNU Free Documentation License''.
45
46 (a) The FSF's Front-Cover Text is:
47
48      A GNU Manual
49
50 (b) The FSF's Back-Cover Text is:
51
52      You have freedom to copy and modify this GNU Manual, like GNU
53      software.  Copies published by the Free Software Foundation raise
54      funds for GNU development.
55 @end ifinfo
56
57 @titlepage
58 @title GNU gcj
59 @author Tom Tromey
60
61 @page
62 @vskip 0pt plus 1filll
63 Copyright @copyright{} @value{copyrights-gcj} Free Software Foundation, Inc.
64 @sp 2
65 For the @value{which-gcj} Version*
66 @sp 1
67 Published by the Free Software Foundation @*
68 59 Temple Place - Suite 330@*
69 Boston, MA 02111-1307, USA@*
70 @sp 1
71 Permission is granted to copy, distribute and/or modify this document
72 under the terms of the GNU Free Documentation License, Version 1.1 or
73 any later version published by the Free Software Foundation; with the
74 Invariant Sections being ``GNU General Public License'', the Front-Cover
75 texts being (a) (see below), and with the Back-Cover Texts being (b)
76 (see below).  A copy of the license is included in the section entitled
77 ``GNU Free Documentation License''.
78
79 (a) The FSF's Front-Cover Text is:
80
81      A GNU Manual
82
83 (b) The FSF's Back-Cover Text is:
84
85      You have freedom to copy and modify this GNU Manual, like GNU
86      software.  Copies published by the Free Software Foundation raise
87      funds for GNU development.
88 @end titlepage
89 @contents
90 @page
91
92
93 @node Top
94 @top Introduction
95
96 This manual describes how to use @code{gcj}, the GNU compiler for the
97 Java programming language.  @code{gcj} can generate both @file{.class}
98 files and object files, and it can read both Java source code and
99 @file{.class} files.
100
101 @menu
102 * Copying::             The GNU General Public License
103 * GNU Free Documentation License::
104                         How you can share and copy this manual
105 * Invoking gcj::        Compiler options supported by @code{gcj}
106 * Compatibility::       Compatibility between gcj and other tools for Java
107 * Invoking gcjh::       Generate header files from class files
108 * Invoking jv-scan::    Print information about source files
109 * Invoking jcf-dump::   Print information about class files
110 * Invoking gij::        Interpreting Java bytecodes
111 * Resources::           Where to look for more information
112 @end menu
113
114
115 @node Copying
116 @unnumbered GNU GENERAL PUBLIC LICENSE
117 @center Version 2, June 1991
118
119 @display
120 Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
121 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
122
123 Everyone is permitted to copy and distribute verbatim copies
124 of this license document, but changing it is not allowed.
125 @end display
126
127 @unnumberedsec Preamble
128
129   The licenses for most software are designed to take away your
130 freedom to share and change it.  By contrast, the GNU General Public
131 License is intended to guarantee your freedom to share and change free
132 software---to make sure the software is free for all its users.  This
133 General Public License applies to most of the Free Software
134 Foundation's software and to any other program whose authors commit to
135 using it.  (Some other Free Software Foundation software is covered by
136 the GNU Library General Public License instead.)  You can apply it to
137 your programs, too.
138
139   When we speak of free software, we are referring to freedom, not
140 price.  Our General Public Licenses are designed to make sure that you
141 have the freedom to distribute copies of free software (and charge for
142 this service if you wish), that you receive source code or can get it
143 if you want it, that you can change the software or use pieces of it
144 in new free programs; and that you know you can do these things.
145
146   To protect your rights, we need to make restrictions that forbid
147 anyone to deny you these rights or to ask you to surrender the rights.
148 These restrictions translate to certain responsibilities for you if you
149 distribute copies of the software, or if you modify it.
150
151   For example, if you distribute copies of such a program, whether
152 gratis or for a fee, you must give the recipients all the rights that
153 you have.  You must make sure that they, too, receive or can get the
154 source code.  And you must show them these terms so they know their
155 rights.
156
157   We protect your rights with two steps: (1) copyright the software, and
158 (2) offer you this license which gives you legal permission to copy,
159 distribute and/or modify the software.
160
161   Also, for each author's protection and ours, we want to make certain
162 that everyone understands that there is no warranty for this free
163 software.  If the software is modified by someone else and passed on, we
164 want its recipients to know that what they have is not the original, so
165 that any problems introduced by others will not reflect on the original
166 authors' reputations.
167
168   Finally, any free program is threatened constantly by software
169 patents.  We wish to avoid the danger that redistributors of a free
170 program will individually obtain patent licenses, in effect making the
171 program proprietary.  To prevent this, we have made it clear that any
172 patent must be licensed for everyone's free use or not licensed at all.
173
174   The precise terms and conditions for copying, distribution and
175 modification follow.
176
177 @iftex
178 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
179 @end iftex
180 @ifinfo
181 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
182 @end ifinfo
183
184 @enumerate 0
185 @item
186 This License applies to any program or other work which contains
187 a notice placed by the copyright holder saying it may be distributed
188 under the terms of this General Public License.  The ``Program'', below,
189 refers to any such program or work, and a ``work based on the Program''
190 means either the Program or any derivative work under copyright law:
191 that is to say, a work containing the Program or a portion of it,
192 either verbatim or with modifications and/or translated into another
193 language.  (Hereinafter, translation is included without limitation in
194 the term ``modification''.)  Each licensee is addressed as ``you''.
195
196 Activities other than copying, distribution and modification are not
197 covered by this License; they are outside its scope.  The act of
198 running the Program is not restricted, and the output from the Program
199 is covered only if its contents constitute a work based on the
200 Program (independent of having been made by running the Program).
201 Whether that is true depends on what the Program does.
202
203 @item
204 You may copy and distribute verbatim copies of the Program's
205 source code as you receive it, in any medium, provided that you
206 conspicuously and appropriately publish on each copy an appropriate
207 copyright notice and disclaimer of warranty; keep intact all the
208 notices that refer to this License and to the absence of any warranty;
209 and give any other recipients of the Program a copy of this License
210 along with the Program.
211
212 You may charge a fee for the physical act of transferring a copy, and
213 you may at your option offer warranty protection in exchange for a fee.
214
215 @item
216 You may modify your copy or copies of the Program or any portion
217 of it, thus forming a work based on the Program, and copy and
218 distribute such modifications or work under the terms of Section 1
219 above, provided that you also meet all of these conditions:
220
221 @enumerate a
222 @item
223 You must cause the modified files to carry prominent notices
224 stating that you changed the files and the date of any change.
225
226 @item
227 You must cause any work that you distribute or publish, that in
228 whole or in part contains or is derived from the Program or any
229 part thereof, to be licensed as a whole at no charge to all third
230 parties under the terms of this License.
231
232 @item
233 If the modified program normally reads commands interactively
234 when run, you must cause it, when started running for such
235 interactive use in the most ordinary way, to print or display an
236 announcement including an appropriate copyright notice and a
237 notice that there is no warranty (or else, saying that you provide
238 a warranty) and that users may redistribute the program under
239 these conditions, and telling the user how to view a copy of this
240 License.  (Exception: if the Program itself is interactive but
241 does not normally print such an announcement, your work based on
242 the Program is not required to print an announcement.)
243 @end enumerate
244
245 These requirements apply to the modified work as a whole.  If
246 identifiable sections of that work are not derived from the Program,
247 and can be reasonably considered independent and separate works in
248 themselves, then this License, and its terms, do not apply to those
249 sections when you distribute them as separate works.  But when you
250 distribute the same sections as part of a whole which is a work based
251 on the Program, the distribution of the whole must be on the terms of
252 this License, whose permissions for other licensees extend to the
253 entire whole, and thus to each and every part regardless of who wrote it.
254
255 Thus, it is not the intent of this section to claim rights or contest
256 your rights to work written entirely by you; rather, the intent is to
257 exercise the right to control the distribution of derivative or
258 collective works based on the Program.
259
260 In addition, mere aggregation of another work not based on the Program
261 with the Program (or with a work based on the Program) on a volume of
262 a storage or distribution medium does not bring the other work under
263 the scope of this License.
264
265 @item
266 You may copy and distribute the Program (or a work based on it,
267 under Section 2) in object code or executable form under the terms of
268 Sections 1 and 2 above provided that you also do one of the following:
269
270 @enumerate a
271 @item
272 Accompany it with the complete corresponding machine-readable
273 source code, which must be distributed under the terms of Sections
274 1 and 2 above on a medium customarily used for software interchange; or,
275
276 @item
277 Accompany it with a written offer, valid for at least three
278 years, to give any third party, for a charge no more than your
279 cost of physically performing source distribution, a complete
280 machine-readable copy of the corresponding source code, to be
281 distributed under the terms of Sections 1 and 2 above on a medium
282 customarily used for software interchange; or,
283
284 @item
285 Accompany it with the information you received as to the offer
286 to distribute corresponding source code.  (This alternative is
287 allowed only for noncommercial distribution and only if you
288 received the program in object code or executable form with such
289 an offer, in accord with Subsection b above.)
290 @end enumerate
291
292 The source code for a work means the preferred form of the work for
293 making modifications to it.  For an executable work, complete source
294 code means all the source code for all modules it contains, plus any
295 associated interface definition files, plus the scripts used to
296 control compilation and installation of the executable.  However, as a
297 special exception, the source code distributed need not include
298 anything that is normally distributed (in either source or binary
299 form) with the major components (compiler, kernel, and so on) of the
300 operating system on which the executable runs, unless that component
301 itself accompanies the executable.
302
303 If distribution of executable or object code is made by offering
304 access to copy from a designated place, then offering equivalent
305 access to copy the source code from the same place counts as
306 distribution of the source code, even though third parties are not
307 compelled to copy the source along with the object code.
308
309 @item
310 You may not copy, modify, sublicense, or distribute the Program
311 except as expressly provided under this License.  Any attempt
312 otherwise to copy, modify, sublicense or distribute the Program is
313 void, and will automatically terminate your rights under this License.
314 However, parties who have received copies, or rights, from you under
315 this License will not have their licenses terminated so long as such
316 parties remain in full compliance.
317
318 @item
319 You are not required to accept this License, since you have not
320 signed it.  However, nothing else grants you permission to modify or
321 distribute the Program or its derivative works.  These actions are
322 prohibited by law if you do not accept this License.  Therefore, by
323 modifying or distributing the Program (or any work based on the
324 Program), you indicate your acceptance of this License to do so, and
325 all its terms and conditions for copying, distributing or modifying
326 the Program or works based on it.
327
328 @item
329 Each time you redistribute the Program (or any work based on the
330 Program), the recipient automatically receives a license from the
331 original licensor to copy, distribute or modify the Program subject to
332 these terms and conditions.  You may not impose any further
333 restrictions on the recipients' exercise of the rights granted herein.
334 You are not responsible for enforcing compliance by third parties to
335 this License.
336
337 @item
338 If, as a consequence of a court judgment or allegation of patent
339 infringement or for any other reason (not limited to patent issues),
340 conditions are imposed on you (whether by court order, agreement or
341 otherwise) that contradict the conditions of this License, they do not
342 excuse you from the conditions of this License.  If you cannot
343 distribute so as to satisfy simultaneously your obligations under this
344 License and any other pertinent obligations, then as a consequence you
345 may not distribute the Program at all.  For example, if a patent
346 license would not permit royalty-free redistribution of the Program by
347 all those who receive copies directly or indirectly through you, then
348 the only way you could satisfy both it and this License would be to
349 refrain entirely from distribution of the Program.
350
351 If any portion of this section is held invalid or unenforceable under
352 any particular circumstance, the balance of the section is intended to
353 apply and the section as a whole is intended to apply in other
354 circumstances.
355
356 It is not the purpose of this section to induce you to infringe any
357 patents or other property right claims or to contest validity of any
358 such claims; this section has the sole purpose of protecting the
359 integrity of the free software distribution system, which is
360 implemented by public license practices.  Many people have made
361 generous contributions to the wide range of software distributed
362 through that system in reliance on consistent application of that
363 system; it is up to the author/donor to decide if he or she is willing
364 to distribute software through any other system and a licensee cannot
365 impose that choice.
366
367 This section is intended to make thoroughly clear what is believed to
368 be a consequence of the rest of this License.
369
370 @item
371 If the distribution and/or use of the Program is restricted in
372 certain countries either by patents or by copyrighted interfaces, the
373 original copyright holder who places the Program under this License
374 may add an explicit geographical distribution limitation excluding
375 those countries, so that distribution is permitted only in or among
376 countries not thus excluded.  In such case, this License incorporates
377 the limitation as if written in the body of this License.
378
379 @item
380 The Free Software Foundation may publish revised and/or new versions
381 of the General Public License from time to time.  Such new versions will
382 be similar in spirit to the present version, but may differ in detail to
383 address new problems or concerns.
384
385 Each version is given a distinguishing version number.  If the Program
386 specifies a version number of this License which applies to it and ``any
387 later version'', you have the option of following the terms and conditions
388 either of that version or of any later version published by the Free
389 Software Foundation.  If the Program does not specify a version number of
390 this License, you may choose any version ever published by the Free Software
391 Foundation.
392
393 @item
394 If you wish to incorporate parts of the Program into other free
395 programs whose distribution conditions are different, write to the author
396 to ask for permission.  For software which is copyrighted by the Free
397 Software Foundation, write to the Free Software Foundation; we sometimes
398 make exceptions for this.  Our decision will be guided by the two goals
399 of preserving the free status of all derivatives of our free software and
400 of promoting the sharing and reuse of software generally.
401
402 @iftex
403 @heading NO WARRANTY
404 @end iftex
405 @ifinfo
406 @center NO WARRANTY
407 @end ifinfo
408
409 @item
410 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
411 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
412 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
413 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
414 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
415 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
416 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
417 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
418 REPAIR OR CORRECTION.
419
420 @item
421 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
422 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
423 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
424 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
425 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
426 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
427 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
428 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
429 POSSIBILITY OF SUCH DAMAGES.
430 @end enumerate
431
432 @iftex
433 @heading END OF TERMS AND CONDITIONS
434 @end iftex
435 @ifinfo
436 @center END OF TERMS AND CONDITIONS
437 @end ifinfo
438
439 @page
440 @unnumberedsec How to Apply These Terms to Your New Programs
441
442   If you develop a new program, and you want it to be of the greatest
443 possible use to the public, the best way to achieve this is to make it
444 free software which everyone can redistribute and change under these terms.
445
446   To do so, attach the following notices to the program.  It is safest
447 to attach them to the start of each source file to most effectively
448 convey the exclusion of warranty; and each file should have at least
449 the ``copyright'' line and a pointer to where the full notice is found.
450
451 @smallexample
452 @var{one line to give the program's name and a brief idea of what it does.}
453 Copyright (C) @var{year}  @var{name of author}
454
455 This program is free software; you can redistribute it and/or modify
456 it under the terms of the GNU General Public License as published by
457 the Free Software Foundation; either version 2 of the License, or
458 (at your option) any later version.
459
460 This program is distributed in the hope that it will be useful,
461 but WITHOUT ANY WARRANTY; without even the implied warranty of
462 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
463 GNU General Public License for more details.
464
465 You should have received a copy of the GNU General Public License
466 along with this program; if not, write to the Free Software
467 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
468 @end smallexample
469
470 Also add information on how to contact you by electronic and paper mail.
471
472 If the program is interactive, make it output a short notice like this
473 when it starts in an interactive mode:
474
475 @smallexample
476 Gnomovision version 69, Copyright (C) @var{year} @var{name of author}
477 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
478 type `show w'.
479 This is free software, and you are welcome to redistribute it
480 under certain conditions; type `show c' for details.
481 @end smallexample
482
483 The hypothetical commands @samp{show w} and @samp{show c} should show
484 the appropriate parts of the General Public License.  Of course, the
485 commands you use may be called something other than @samp{show w} and
486 @samp{show c}; they could even be mouse-clicks or menu items---whatever
487 suits your program.
488
489 You should also get your employer (if you work as a programmer) or your
490 school, if any, to sign a ``copyright disclaimer'' for the program, if
491 necessary.  Here is a sample; alter the names:
492
493 @smallexample
494 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
495 `Gnomovision' (which makes passes at compilers) written by James Hacker.
496
497 @var{signature of Ty Coon}, 1 April 1989
498 Ty Coon, President of Vice
499 @end smallexample
500
501 This General Public License does not permit incorporating your program into
502 proprietary programs.  If your program is a subroutine library, you may
503 consider it more useful to permit linking proprietary applications with the
504 library.  If this is what you want to do, use the GNU Library General
505 Public License instead of this License.
506
507
508 @include fdl.texi
509
510
511 @node Invoking gcj
512 @chapter Invoking gcj
513
514 As @code{gcj} is just another front end to @code{gcc}, it supports many
515 of the same options as gcc.  @xref{Option Summary, , Option Summary,
516 gcc, Using the GNU Compiler Collection}.  This manual only documents the
517 options specific to @code{gcj}.
518
519 @menu
520 * Input and output files::
521 * Input Options::               How gcj finds files
522 * Encodings::                   Options controlling source file encoding
523 * Warnings::                    Options controlling warnings specific to gcj
524 * Code Generation::             Options controlling the output of gcj
525 * Configure-time Options::      Options you won't use
526 @end menu
527
528 @node Input and output files
529 @section Input and output files
530
531 A @code{gcj} command is like a @code{gcc} command, in that it
532 consists of a number of options and file names.  The following kinds
533 of input file names are supported:
534
535 @table @code
536 @item @var{file}.java
537 Java source files.
538 @item @var{file}.class
539 Java bytecode files.
540 @item @var{file}.zip
541 @itemx @var{file}.jar
542 An archive containing one or more @code{.class} files, all of
543 which are compiled.  The archive may be compressed.
544 @item @@@var{file}
545 A file containing a whitespace-separated list of input file names.
546 (Currently, these must all be @code{.java} source files, but that
547 may change.)
548 Each named file is compiled, just as if it had been on the command line.
549 @item @var{library}.a
550 @itemx @var{library}.so
551 @itemx -l@var{libname}
552 Libraries to use when linking.  See the @code{gcc} manual.
553 @end table
554
555 You can specify more than one input file on the @code{gcj} command line,
556 in which case they will all be compiled.  If you specify a
557 @code{-o @var{FILENAME}}
558 option, all the input files will be compiled together, producing a
559 single output file, named @var{FILENAME}.
560 This is allowed even when using @code{-S} or @code{-c},
561 but not when using @code{-C}.
562 (This is an extension beyond the what plain @code{gcc} allows.)
563 (If more than one input file is specified, all must currently
564 be @code{.java} files, though we hope to fix this.)
565
566 @node Input Options
567 @section Input Options
568
569 @cindex class path
570
571 @code{gcj} has options to control where it looks to find files it needs.
572 For instance, @code{gcj} might need to load a class that is referenced
573 by the file it has been asked to compile.  Like other compilers for the
574 Java language, @code{gcj} has a notion of a @dfn{class path}.  There are
575 several options and environment variables which can be used to
576 manipulate the class path.  When @code{gcj} looks for a given class, it
577 searches the class path looking for matching @file{.class} or
578 @file{.java} file.  @code{gcj} comes with a built-in class path which
579 points at the installed @file{libgcj.jar}, a file which contains all the
580 standard classes.
581
582 In the below, a directory or path component can refer either to an
583 actual directory on the filesystem, or to a @file{.zip} or @file{.jar}
584 file, which @code{gcj} will search as if it is a directory.
585
586 @table @code
587 @item -I@var{dir}
588 All directories specified by @code{-I} are kept in order and prepended
589 to the class path constructed from all the other options.  Unless
590 compatibility with tools like @code{javac} is imported, we recommend
591 always using @code{-I} instead of the other options for manipulating the
592 class path.
593
594 @item --classpath=@var{path}
595 This sets the class path to @var{path}, a colon-separated list of paths
596 (on Windows-based systems, a semicolon-separate list of paths).
597
598 @item --CLASSPATH=@var{path}
599 This sets the class path to @var{path}, a colon-separated list of paths
600 (on Windows-based systems, a semicolon-separate list of paths).  This
601 differs from the @code{--classpath} option in that it also suppresses
602 the built-in system path.
603
604 @item CLASSPATH
605 This is an environment variable which holds a list of paths.
606 @end table
607
608 The final class path is constructed like so:
609
610 @itemize @bullet
611 @item
612 First come all directories specified via @code{-I}.
613
614 @item
615 If @code{--classpath} is specified, its value is appended and processing
616 stops.  That is, @code{--classpath} suppresses all the options mentioned
617 later in this list.
618
619 @item
620 If @code{--CLASSPATH} is specified, its value is appended and the
621 @code{CLASSPATH} environment variable is suppressed.
622
623 @item
624 If the @code{CLASSPATH} environment variable is specified (and was not
625 suppressed by @code{--CLASSPATH}), then its value is appended.
626
627 @item
628 Finally, the built-in system directory, @file{libgcj.jar}, is appended.
629 @end itemize
630
631 The classfile built by @code{gcj} for the class @code{java.lang.Object}
632 (and placed in @code{libgcj.jar}) contains a special zero length
633 attribute @code{gnu.gcj.gcj-compiled}. The compiler looks for this
634 attribute when loading @code{java.lang.Object} and will report an error
635 if it isn't found, unless it compiles to bytecode (the option
636 @code{-fforce-classes-archive-check} can be used to overide this
637 behavior in this particular case.)
638
639 @table @code
640 @item -fforce-classes-archive-check
641 This forces the compiler to always check for the special zero length
642 attribute @code{gnu.gcj.gcj-compiled} in @code{java.lang.Object} and
643 issue an error if it isn't found.
644 @end table
645
646 @node Encodings
647 @section Encodings
648
649 The Java programming language uses Unicode throughout.  In an effort to
650 integrate well with other locales, @code{gcj} allows @file{.java} files
651 to be written using almost any encoding.  @code{gcj} knows how to
652 convert these encodings into its internal encoding at compile time.
653
654 You can use the @code{--encoding=@var{NAME}} option to specify an
655 encoding (of a particular character set) to use for source files.  If
656 this is not specified, the default encoding comes from your current
657 locale.  If your host system has insufficient locale support, then
658 @code{gcj} assumes the default encoding to be the @samp{UTF-8} encoding
659 of Unicode.
660
661 To implement @code{--encoding}, @code{gcj} simply uses the host
662 platform's @code{iconv} conversion routine.  This means that in practice
663 @code{gcj} is limited by the capabilities of the host platform.
664
665 The names allowed for the argument @code{--encoding} vary from platform
666 to platform (since they are not standardized anywhere).  However,
667 @code{gcj} implements the encoding named @samp{UTF-8} internally, so if
668 you choose to use this for your source files you can be assured that it
669 will work on every host.
670
671
672 @node Warnings
673 @section Warnings
674
675 @code{gcj} implements several warnings.  As with other generic
676 @code{gcc} warnings, if an option of the form @code{-Wfoo} enables a
677 warning, then @code{-Wno-foo} will disable it.  Here we've chosen to
678 document the form of the warning which will have an effect -- the
679 default being the opposite of what is listed.
680
681 @table @code
682 @item -Wredundant-modifiers
683 With this flag, @code{gcj} will warn about redundant modifiers.  For
684 instance, it will warn if an interface method is declared @code{public}.
685
686 @item -Wextraneous-semicolon
687 This causes @code{gcj} to warn about empty statements.  Empty statements
688 have been deprecated.
689
690 @item -Wno-out-of-date
691 This option will cause @code{gcj} not to warn when a source file is
692 newer than its matching class file.  By default @code{gcj} will warn
693 about this.
694
695 @item -Wunused
696 This is the same as @code{gcc}'s @code{-Wunused}.
697
698 @item -Wall
699 This is the same as @code{-Wredundant-modifiers -Wextraneous-semicolon
700 -Wunused}.
701 @end table
702
703
704 @node Code Generation
705 @section Code Generation
706
707 In addition to the many @code{gcc} options controlling code generation,
708 @code{gcj} has several options specific to itself.
709
710 @table @code
711 @item --main=@var{CLASSNAME}
712 This option is used when linking to specify the name of the class whose
713 @code{main} method should be invoked when the resulting executable is
714 run.  @footnote{The linker by default looks for a global function named
715 @code{main}.  Since Java does not have global functions, and a
716 collection of Java classes may have more than one class with a
717 @code{main} method, you need to let the linker know which of those
718 @code{main} methods it should invoke when starting the application.}
719
720 @item -D@var{name}[=@var{value}]
721 This option can only be used with @code{--main}.  It defines a system
722 property named @var{name} with value @var{value}.  If @var{value} is not
723 specified then it defaults to the empty string.  These system properties
724 are initialized at the program's startup and can be retrieved at runtime
725 using the @code{java.lang.System.getProperty} method.
726
727 @item -C
728 This option is used to tell @code{gcj} to generate bytecode
729 (@file{.class} files) rather than object code.
730
731 @item -d @var{directory}
732 When used with @code{-C}, this causes all generated @file{.class} files
733 to be put in the appropriate subdirectory of @var{directory}.  By
734 default they will be put in subdirectories of the current working
735 directory.
736
737 @item -fno-bounds-check
738 By default, @code{gcj} generates code which checks the bounds of all
739 array indexing operations.  With this option, these checks are omitted.
740 Note that this can result in unpredictable behavior if the code in
741 question actually does violate array bounds constraints.
742
743 @item -fjni
744 With @code{gcj} there are two options for writing native methods: CNI
745 and JNI.  By default @code{gcj} assumes you are using CNI.  If you are
746 compiling a class with native methods, and these methods are implemented
747 using JNI, then you must use @code{-fjni}.  This option causes
748 @code{gcj} to generate stubs which will invoke the underlying JNI
749 methods.
750 @end table
751
752
753 @node Configure-time Options
754 @section Configure-time Options
755
756 Some @code{gcj} code generations options affect the resulting ABI, and
757 so can only be meaningfully given when @code{libgcj}, the runtime
758 package, is configured.  @code{libgcj} puts the appropriate options from
759 this group into a @samp{spec} file which is read by @code{gcj}.  These
760 options are listed here for completeness; if you are using @code{libgcj}
761 then you won't want to touch these options.
762
763 @table @code
764 @item -fuse-boehm-gc
765 This enables the use of the Boehm GC bitmap marking code.  In particular
766 this causes @code{gcj} to put an object marking descriptor into each
767 vtable.
768
769 @item -fhash-synchronization
770 By default, synchronization data (the data used for @code{synchronize},
771 @code{wait}, and @code{notify}) is pointed to by a word in each object.
772 With this option @code{gcj} assumes that this information is stored in a
773 hash table and not in the object itself.
774
775 @item -fuse-divide-subroutine
776 On some systems, a library routine is called to perform integer
777 division.  This is required to get exception handling correct when
778 dividing by zero.
779
780 @item -fcheck-references
781 On some systems it's necessary to insert inline checks whenever
782 accessing an object via a reference.  On other systems you won't need
783 this because null pointer accesses are caught automatically by the
784 processor.
785 @end table
786
787
788 @node Compatibility
789 @chapter Compatibility with the Java Platform
790
791 As we believe it is important that the Java platform not be fragmented,
792 @code{gcj} and @code{libgcj} try to conform to the relevant Java
793 specifications.  However, limited manpower and incomplete and unclear
794 documentation work against us.  So, there are caveats to using
795 @code{gcj}.
796
797 This list of compatibility issues is by no means complete.
798
799 @itemize @bullet
800 @item
801 @code{gcj} implements the JDK 1.1 language.  It supports inner classes,
802 though these are known to still be buggy.  It does not yet support the
803 Java 2 @code{strictfp} keyword (it recognizes the keyword but ignores
804 it).
805
806 @item
807 @code{libgcj} is largely compatible with the JDK 1.2 libraries.
808 However, @code{libgcj} is missing many packages, most notably
809 @code{java.awt}.  There are also individual missing classes and methods.
810 We currently do not have a list showing differences between
811 @code{libgcj} and the Java 2 platform.
812
813 @item
814 Sometimes the @code{libgcj} implementation of a method or class differs
815 from the JDK implementation.  This is not always a bug.  Still, if it
816 affects you, it probably makes sense to report it so that we can discuss
817 the appropriate response.
818 @end itemize
819
820
821 @node Invoking gcjh
822 @chapter Invoking gcjh
823
824 The @code{gcjh} program is used to generate header files from class
825 files.  It can generate both CNI and JNI header files, as well as stub
826 implementation files which can be used as a basis for implementing the
827 required native methods.
828
829 @table @code
830 @item -stubs
831 This causes @code{gcjh} to generate stub files instead of header files.
832 By default the stub file will be named after the class, with a suffix of
833 @samp{.cc}.  In JNI mode, the default output file will have the suffix
834 @samp{.c}.
835
836 @item -jni
837 This tells @code{gcjh} to generate a JNI header or stub.  By default,
838 CNI headers are generated.
839
840 @item -add @var{text}
841 Inserts @var{text} into the class body.  This is ignored in JNI mode.
842
843 @item -append @var{text}
844 Inserts @var{text} into the header file after the class declaration.
845 This is ignored in JNI mode.
846
847 @item -friend @var{text}
848 Inserts @var{text} into the class as a @code{friend} declaration.
849 This is ignored in JNI mode.
850
851 @item -prepend @var{text}
852 Inserts @var{text} into the header file before the class declaration.
853 This is ignored in JNI mode.
854
855 @item --classpath=@var{path}
856 @itemx --CLASSPATH=@var{path}
857 @itemx -I@var{directory}
858 @itemx -d @var{directory}
859 @itemx -o @var{file}
860 These options are all identical to the corresponding @code{gcj} options.
861
862 @item -o @var{file}
863 Sets the output file name.  This cannot be used if there is more than
864 one class on the command line.
865
866 @item -td @var{directory}
867 Sets the name of the directory to use for temporary files.
868
869 @item --help
870 Print help about @code{gcjh} and exit.  No further processing is done.
871
872 @item --version
873 Print version information for @code{gcjh} and exit.  No further
874 processing is done.
875 @end table
876
877 All remaining options are considered to be names of classes.
878
879
880 @node Invoking jv-scan
881 @chapter Invoking jv-scan
882
883 The @code{jv-scan} program can be used to print information about a Java
884 source file (@file{.java} file).
885
886 @table @code
887 @item --complexity
888 This prints a complexity measure, related to cyclomatic complexity, for
889 each input file.
890
891 @item --encoding=@var{name}
892 This works like the corresponding @code{gcj} option.
893
894 @item --print-main
895 This prints the name of the class in this file containing a @code{main}
896 method.
897
898 @item --list-class
899 This lists the names of all classes defined in the input files.
900
901 @item --list-filename
902 If @code{--list-class} is given, this option causes @code{jv-scan} to
903 also print the name of the file in which each class was found.
904
905 @item -o @var{file}
906 Print output to the named file.
907 @end table
908
909
910 @node Invoking jcf-dump
911 @chapter Invoking jcf-dump
912
913 This is a class file examiner, similar to @code{javap}.  It will print
914 information about a number of classes, which are specifed by class name
915 or file name.
916
917 @table @code
918 @item -c
919 Disassemble method bodies.  By default method bodies are not printed.
920
921 @item --javap
922 Generate output in @code{javap} format.  The implementation of this
923 feature is very incomplete.
924
925 @item --classpath=@var{path}
926 @itemx --CLASSPATH=@var{path}
927 @itemx -I@var{directory}
928 @itemx -o @var{file}
929 These options as the same as the corresponding @code{gcj} options.
930 @end table
931
932
933 @node Invoking gij
934 @chapter Invoking gij
935
936 @code{gij} is a Java bytecode interpreter included with @code{libgcj}.
937 @code{gij} is not available on every platform; porting it requires a
938 small amount of assembly programming which has not been done for all the
939 targets supported by @code{gcj}.
940
941 The primary argument to @code{gij} is the name of a class or, with
942 @code{-jar}, a jar file.  Options before this argument are interpreted
943 by @code{gij}; remaining options are passed to the interpreted program.
944
945 If a class name is specified and this class does not have a @code{main}
946 method with the appropriate signature (a @code{static void} method with
947 a @code{String[]} as its sole argument), then @code{gij} will print an
948 error and exit.
949
950 If a jar file is specified then @code{gij} will use information in it to
951 determine which class' @code{main} method will be invoked.
952
953 @code{gij} will invoke the @code{main} method with all the remaining
954 command-line options.
955
956 Note that @code{gij} is not limited to interpreting code.  Because
957 @code{libgcj} includes a class loader which can dynamically load shared
958 objects, it is possible to give @code{gij} the name of a class which has
959 been compiled and put into a shared library on the class path.
960
961 @table @code
962 @item -D@var{name}[=@var{value}]
963 This defines a system property named @var{name} with value @var{value}.
964 If @var{value} is not specified then it defaults to the empty string.
965 These system properties are initialized at the program's startup and can
966 be retrieved at runtime using the @code{java.lang.System.getProperty}
967 method.
968
969 @item -ms=@var{number}
970 This sets the initial heap size 
971
972 @item -mx=@var{number}
973 This sets the maximum heap size.
974
975 @item -jar
976 This indicates that the name passed to @code{gij} should be interpreted
977 as the name of a jar file, not a class.
978 @end table
979
980
981 @node Resources
982 @chapter Resources
983
984 While writing @code{gcj} and @code{libgcj} we have, of course, relied
985 heavily on documentation from Sun Microsystems.  In particular we have
986 used The Java Language Specification (both first and second editions),
987 the Java Class Libraries (volumes one and two), and the Java Virtual
988 Machine Specification.  In addition we've used the online documentation
989 at @uref{http://java.sun.com/}.
990
991 The current @code{gcj} home page is
992 @uref{http://gcc.gnu.org/java/}.
993
994 For more information on gcc, see @uref{http://gcc.gnu.org/}.
995
996 Some @code{libgcj} testing is done using the Mauve test suite.  This is
997 a free software Java class library test suite which is being written
998 because the JCK is not free.  See
999 @uref{http://sources.redhat.com/mauve/} for more information.
1000
1001 @bye