1GCJ(1)                                GNU                               GCJ(1)
2
3
4

NAME

6       gcj - Ahead-of-time compiler for the Java language
7

SYNOPSIS

9       gcj [-Idir...] [-d dir...]
10           [--CLASSPATH=path] [--classpath=path]
11           [-foption...] [--encoding=name]
12           [--main=classname] [-Dname[=value]...]
13           [-C] [--resource resource-name] [-d directory]
14           [-Wwarn...]
15           sourcefile...
16

DESCRIPTION

18       As gcj is just another front end to gcc, it supports many of the same
19       options as gcc.    This manual only documents the options specific to
20       gcj.
21

OPTIONS

23       Input and output files
24
25       A gcj command is like a gcc command, in that it consists of a number of
26       options and file names.  The following kinds of input file names are
27       supported:
28
29       file.java
30           Java source files.
31
32       file.class
33           Java bytecode files.
34
35       file.zip
36       file.jar
37           An archive containing one or more ".class" files, all of which are
38           compiled.  The archive may be compressed.  Files in an archive
39           which don't end with .class are treated as resource files; they are
40           compiled into the resulting object file as core: URLs.
41
42       @file
43           A file containing a whitespace-separated list of input file names.
44           (Currently, these must all be ".java" source files, but that may
45           change.)  Each named file is compiled, just as if it had been on
46           the command line.
47
48       library.a
49       library.so
50       -llibname
51           Libraries to use when linking.  See the gcc manual.
52
53       You can specify more than one input file on the gcj command line, in
54       which case they will all be compiled.  If you specify a "-o FILENAME"
55       option, all the input files will be compiled together, producing a sin‐
56       gle output file, named FILENAME.  This is allowed even when using "-S"
57       or "-c", but not when using "-C" or "--resource".  (This is an exten‐
58       sion beyond the what plain gcc allows.)  (If more than one input file
59       is specified, all must currently be ".java" files, though we hope to
60       fix this.)
61
62       Input Options
63
64       gcj has options to control where it looks to find files it needs.  For
65       instance, gcj might need to load a class that is referenced by the file
66       it has been asked to compile.  Like other compilers for the Java lan‐
67       guage, gcj has a notion of a class path.  There are several options and
68       environment variables which can be used to manipulate the class path.
69       When gcj looks for a given class, it searches the class path looking
70       for matching .class or .java file.  gcj comes with a built-in class
71       path which points at the installed libgcj.jar, a file which contains
72       all the standard classes.
73
74       In the below, a directory or path component can refer either to an
75       actual directory on the filesystem, or to a .zip or .jar file, which
76       gcj will search as if it is a directory.
77
78       -Idir
79           All directories specified by "-I" are kept in order and prepended
80           to the class path constructed from all the other options.  Unless
81           compatibility with tools like "javac" is important, we recommend
82           always using "-I" instead of the other options for manipulating the
83           class path.
84
85       --classpath=path
86           This sets the class path to path, a colon-separated list of paths
87           (on Windows-based systems, a semicolon-separate list of paths).
88           This does not override the builtin ("boot") search path.
89
90       --CLASSPATH=path
91           Deprecated synonym for "--classpath".
92
93       --bootclasspath=path
94           Where to find the standard builtin classes, such as
95           "java.lang.String".
96
97       --extdirs=path
98           For each directory in the path, place the contents of that direc‐
99           tory at the end of the class path.
100
101       CLASSPATH
102           This is an environment variable which holds a list of paths.
103
104       The final class path is constructed like so:
105
106       ·   First come all directories specified via "-I".
107
108       ·   If --classpath is specified, its value is appended.  Otherwise, if
109           the "CLASSPATH" environment variable is specified, then its value
110           is appended.  Otherwise, the current directory (".") is appended.
111
112       ·   If "--bootclasspath" was specified, append its value.  Otherwise,
113           append the built-in system directory, libgcj.jar.
114
115       ·   Finally, if "--extdirs" was specified, append the contents of the
116           specified directories at the end of the class path.  Otherwise,
117           append the contents of the built-in extdirs at "$(pre‐
118           fix)/share/java/ext".
119
120       The classfile built by gcj for the class "java.lang.Object" (and placed
121       in "libgcj.jar") contains a special zero length attribute
122       "gnu.gcj.gcj-compiled". The compiler looks for this attribute when
123       loading "java.lang.Object" and will report an error if it isn't found,
124       unless it compiles to bytecode (the option "-fforce-classes-ar‐
125       chive-check" can be used to override this behavior in this particular
126       case.)
127
128       -fforce-classes-archive-check
129           This forces the compiler to always check for the special zero
130           length attribute "gnu.gcj.gcj-compiled" in "java.lang.Object" and
131           issue an error if it isn't found.
132
133       -fsource=VERSION
134           This option is used to choose the source version accepted by gcj.
135           The default is 1.5.
136
137       Encodings
138
139       The Java programming language uses Unicode throughout.  In an effort to
140       integrate well with other locales, gcj allows .java files to be written
141       using almost any encoding.  gcj knows how to convert these encodings
142       into its internal encoding at compile time.
143
144       You can use the "--encoding=NAME" option to specify an encoding (of a
145       particular character set) to use for source files.  If this is not
146       specified, the default encoding comes from your current locale.  If
147       your host system has insufficient locale support, then gcj assumes the
148       default encoding to be the UTF-8 encoding of Unicode.
149
150       To implement "--encoding", gcj simply uses the host platform's "iconv"
151       conversion routine.  This means that in practice gcj is limited by the
152       capabilities of the host platform.
153
154       The names allowed for the argument "--encoding" vary from platform to
155       platform (since they are not standardized anywhere).  However, gcj
156       implements the encoding named UTF-8 internally, so if you choose to use
157       this for your source files you can be assured that it will work on
158       every host.
159
160       Warnings
161
162       gcj implements several warnings.  As with other generic gcc warnings,
163       if an option of the form "-Wfoo" enables a warning, then "-Wno-foo"
164       will disable it.  Here we've chosen to document the form of the warning
165       which will have an effect -- the default being the opposite of what is
166       listed.
167
168       -Wredundant-modifiers
169           With this flag, gcj will warn about redundant modifiers.  For
170           instance, it will warn if an interface method is declared "public".
171
172       -Wextraneous-semicolon
173           This causes gcj to warn about empty statements.  Empty statements
174           have been deprecated.
175
176       -Wno-out-of-date
177           This option will cause gcj not to warn when a source file is newer
178           than its matching class file.  By default gcj will warn about this.
179
180       -Wno-deprecated
181           Warn if a deprecated class, method, or field is referred to.
182
183       -Wunused
184           This is the same as gcc's "-Wunused".
185
186       -Wall
187           This is the same as "-Wredundant-modifiers -Wextraneous-semicolon
188           -Wunused".
189
190       Linking
191
192       To turn a Java application into an executable program, you need to link
193       it with the needed libraries, just as for C or C++.  The linker by
194       default looks for a global function named "main".  Since Java does not
195       have global functions, and a collection of Java classes may have more
196       than one class with a "main" method, you need to let the linker know
197       which of those "main" methods it should invoke when starting the appli‐
198       cation.  You can do that in any of these ways:
199
200       ·   Specify the class containing the desired "main" method when you
201           link the application, using the "--main" flag, described below.
202
203       ·   Link the Java package(s) into a shared library (dll) rather than an
204           executable.  Then invoke the application using the "gij" program,
205           making sure that "gij" can find the libraries it needs.
206
207       ·   Link the Java packages(s) with the flag "-lgij", which links in the
208           "main" routine from the "gij" command.  This allows you to select
209           the class whose "main" method you want to run when you run the
210           application.  You can also use other "gij" flags, such as "-D"
211           flags to set properties.  Using the "-lgij" library (rather than
212           the "gij" program of the previous mechanism) has some advantages:
213           it is compatible with static linking, and does not require config‐
214           uring or installing libraries.
215
216       These "gij" options relate to linking an executable:
217
218       --main=CLASSNAME
219           This option is used when linking to specify the name of the class
220           whose "main" method should be invoked when the resulting executable
221           is run.
222
223       -Dname[=value]
224           This option can only be used with "--main".  It defines a system
225           property named name with value value.  If value is not specified
226           then it defaults to the empty string.  These system properties are
227           initialized at the program's startup and can be retrieved at run‐
228           time using the "java.lang.System.getProperty" method.
229
230       -lgij
231           Create an application whose command-line processing is that of the
232           "gij" command.
233
234           This option is an alternative to using "--main"; you cannot use
235           both.
236
237       -static-libgcj
238           This option causes linking to be done against a static version of
239           the libgcj runtime library.  This option is only available if cor‐
240           responding linker support exists.
241
242           Caution: Static linking of libgcj may cause essential parts of
243           libgcj to be omitted.  Some parts of libgcj use reflection to load
244           classes at runtime.  Since the linker does not see these references
245           at link time, it can omit the referred to classes.  The result is
246           usually (but not always) a "ClassNotFoundException" being thrown at
247           runtime. Caution must be used when using this option.  For more
248           details see: <http://gcc.gnu.org/wiki/Statically%20link
249           ing%20libgcj>
250
251       Code Generation
252
253       In addition to the many gcc options controlling code generation, gcj
254       has several options specific to itself.
255
256       -C  This option is used to tell gcj to generate bytecode (.class files)
257           rather than object code.
258
259       --resource resource-name
260           This option is used to tell gcj to compile the contents of a given
261           file to object code so it may be accessed at runtime with the core
262           protocol handler as core:/resource-name.  Note that resource-name
263           is the name of the resource as found at runtime; for instance, it
264           could be used in a call to "ResourceBundle.getBundle".  The actual
265           file name to be compiled this way must be specified separately.
266
267       -ftarget=VERSION
268           This can be used with -C to choose the version of bytecode emitted
269           by gcj.  The default is 1.5.  When not generating bytecode, this
270           option has no effect.
271
272       -d directory
273           When used with "-C", this causes all generated .class files to be
274           put in the appropriate subdirectory of directory.  By default they
275           will be put in subdirectories of the current working directory.
276
277       -fno-bounds-check
278           By default, gcj generates code which checks the bounds of all array
279           indexing operations.  With this option, these checks are omitted,
280           which can improve performance for code that uses arrays exten‐
281           sively.  Note that this can result in unpredictable behavior if the
282           code in question actually does violate array bounds constraints.
283           It is safe to use this option if you are sure that your code will
284           never throw an "ArrayIndexOutOfBoundsException".
285
286       -fno-store-check
287           Don't generate array store checks.  When storing objects into
288           arrays, a runtime check is normally generated in order to ensure
289           that the object is assignment compatible with the component type of
290           the array (which may not be known at compile-time).  With this
291           option, these checks are omitted.  This can improve performance for
292           code which stores objects into arrays frequently.  It is safe to
293           use this option if you are sure your code will never throw an
294           "ArrayStoreException".
295
296       -fjni
297           With gcj there are two options for writing native methods: CNI and
298           JNI.  By default gcj assumes you are using CNI.  If you are compil‐
299           ing a class with native methods, and these methods are implemented
300           using JNI, then you must use "-fjni".  This option causes gcj to
301           generate stubs which will invoke the underlying JNI methods.
302
303       -fno-assert
304           Don't recognize the "assert" keyword.  This is for compatibility
305           with older versions of the language specification.
306
307       -fno-optimize-static-class-initialization
308           When the optimization level is greater or equal to "-O2", gcj will
309           try to optimize the way calls into the runtime are made to initial‐
310           ize static classes upon their first use (this optimization isn't
311           carried out if "-C" was specified.) When compiling to native code,
312           "-fno-optimize-static-class-initialization" will turn this opti‐
313           mization off, regardless of the optimization level in use.
314
315       --disable-assertions[=class-or-package]
316           Don't include code for checking assertions in the compiled code.
317           If "=class-or-package" is missing disables assertion code genera‐
318           tion for all classes, unless overridden by a more specific
319           "--enable-assertions" flag.  If class-or-package is a class name,
320           only disables generating assertion checks within the named class or
321           its inner classes.  If class-or-package is a package name, disables
322           generating assertion checks within the named package or a subpack‐
323           age.
324
325           By default, assertions are enabled when generating class files or
326           when not optimizing, and disabled when generating optimized bina‐
327           ries.
328
329       --enable-assertions[=class-or-package]
330           Generates code to check assertions.  The option is perhaps mis‐
331           named, as you still need to turn on assertion checking at run-time,
332           and we don't support any easy way to do that.  So this flag isn't
333           very useful yet, except to partially override "--disable-asser‐
334           tions".
335
336       -findirect-dispatch
337           gcj has a special binary compatibility ABI, which is enabled by the
338           "-findirect-dispatch" option.  In this mode, the code generated by
339           gcj honors the binary compatibility guarantees in the Java Language
340           Specification, and the resulting object files do not need to be
341           directly linked against their dependencies.  Instead, all dependen‐
342           cies are looked up at runtime.  This allows free mixing of inter‐
343           preted and compiled code.
344
345           Note that, at present, "-findirect-dispatch" can only be used when
346           compiling .class files.  It will not work when compiling from
347           source.  CNI also does not yet work with the binary compatibility
348           ABI.  These restrictions will be lifted in some future release.
349
350           However, if you compile CNI code with the standard ABI, you can
351           call it from code built with the binary compatibility ABI.
352
353       -fbootstrap-classes
354           This option can be use to tell "libgcj" that the compiled classes
355           should be loaded by the bootstrap loader, not the system class
356           loader.  By default, if you compile a class and link it into an
357           executable, it will be treated as if it was loaded using the system
358           class loader.  This is convenient, as it means that things like
359           "Class.forName()" will search CLASSPATH to find the desired class.
360
361       -freduced-reflection
362           This option causes the code generated by gcj to contain a reduced
363           amount of the class meta-data used to support runtime reflection.
364           The cost of this savings is the loss of the ability to use certain
365           reflection capabilities of the standard Java runtime environment.
366           When set all meta-data except for that which is needed to obtain
367           correct runtime semantics is eliminated.
368
369           For code that does not use reflection (i.e. the methods in the
370           "java.lang.reflect" package), "-freduced-reflection" will result in
371           proper operation with a savings in executable code size.
372
373           JNI ("-fjni") and the binary compatibility ABI ("-findirect-dis‐
374           patch") do not work properly without full reflection meta-data.
375           Because of this, it is an error to use these options with "-fre‐
376           duced-reflection".
377
378           Caution: If there is no reflection meta-data, code that uses a
379           "SecurityManager" may not work properly.  Also calling "Class.for‐
380           Name()" may fail if the calling method has no reflection meta-data.
381
382       Configure-time Options
383
384       Some gcj code generations options affect the resulting ABI, and so can
385       only be meaningfully given when "libgcj", the runtime package, is con‐
386       figured.  "libgcj" puts the appropriate options from this group into a
387       spec file which is read by gcj.  These options are listed here for com‐
388       pleteness; if you are using "libgcj" then you won't want to touch these
389       options.
390
391       -fuse-boehm-gc
392           This enables the use of the Boehm GC bitmap marking code.  In par‐
393           ticular this causes gcj to put an object marking descriptor into
394           each vtable.
395
396       -fhash-synchronization
397           By default, synchronization data (the data used for "synchronize",
398           "wait", and "notify") is pointed to by a word in each object.  With
399           this option gcj assumes that this information is stored in a hash
400           table and not in the object itself.
401
402       -fuse-divide-subroutine
403           On some systems, a library routine is called to perform integer
404           division.  This is required to get exception handling correct when
405           dividing by zero.
406
407       -fcheck-references
408           On some systems it's necessary to insert inline checks whenever
409           accessing an object via a reference.  On other systems you won't
410           need this because null pointer accesses are caught automatically by
411           the processor.
412

SEE ALSO

414       gcc(1), gcjh(1), gjnih(1), gij(1), jcf-dump(1), gfdl(7), and the Info
415       entries for gcj and gcc.
416
418       Copyright (c) 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
419       Inc.
420
421       Permission is granted to copy, distribute and/or modify this document
422       under the terms of the GNU Free Documentation License, Version 1.2 or
423       any later version published by the Free Software Foundation; with the
424       Invariant Sections being "GNU General Public License", the Front-Cover
425       texts being (a) (see below), and with the Back-Cover Texts being (b)
426       (see below).  A copy of the license is included in the man page
427       gfdl(7).
428
429       (a) The FSF's Front-Cover Text is:
430
431            A GNU Manual
432
433       (b) The FSF's Back-Cover Text is:
434
435            You have freedom to copy and modify this GNU Manual, like GNU
436            software.  Copies published by the Free Software Foundation raise
437            funds for GNU development.
438
439
440
441gcc-4.1.2                         2007-09-25                            GCJ(1)
Impressum