In addition to the many gcc
options controlling code generation,
gcj
has several options specific to itself.
--main=
CLASSNAME
main
method should be invoked when the resulting executable is
run. 1
-D
name[=
value]
--main
. It defines a system
property named name with value value. If value is not
specified then it defaults to the empty string. These system properties
are initialized at the program's startup and can be retrieved at runtime
using the java.lang.System.getProperty
method.
-C
gcj
to generate bytecode
(.class
files) rather than object code.
--resource
resource-name
gcj
to compile the contents of a
given file to object code so it may be accessed at runtime with the core
protocol handler as core:/
resource-name
. Note that
resource-name is the name of the resource as found at runtime; for
instance, it could be used in a call to ResourceBundle.getBundle
.
The actual file name to be compiled this way must be specified
separately.
-d
directory
-C
, this causes all generated .class
files
to be put in the appropriate subdirectory of directory. By
default they will be put in subdirectories of the current working
directory.
-fno-bounds-check
gcj
generates code which checks the bounds of all
array indexing operations. With this option, these checks are omitted, which
can improve performance for code that uses arrays extensively. Note that this
can result in unpredictable behavior if the code in question actually does
violate array bounds constraints. It is safe to use this option if you are
sure that your code will never throw an ArrayIndexOutOfBoundsException
.
-fno-store-check
ArrayStoreException
.
-fjni
gcj
there are two options for writing native methods: CNI
and JNI. By default gcj
assumes you are using CNI. If you are
compiling a class with native methods, and these methods are implemented
using JNI, then you must use -fjni
. This option causes
gcj
to generate stubs which will invoke the underlying JNI
methods.
-fno-optimize-static-class-initialization
-O2
,
gcj
will try to optimize the way calls into the runtime are made
to initialize static classes upon their first use (this optimization
isn't carried out if -C
was specified.) When compiling to native
code, -fno-optimize-static-class-initialization
will turn this
optimization off, regardless of the optimization level in use.
The linker by default looks for a global function named
main
. Since Java does not have global functions, and a
collection of Java classes may have more than one class with a
main
method, you need to let the linker know which of those
main
methods it should invoke when starting the application.