Java Reference
In-Depth Information
-source <version>
Control the Java version that javac will accept.
-target <version>
Control the version of class files that javac will output.
-proile <proile>
Control the profile that javac will use when compiling the application. See
later in this chapter for more detail on Compact Profiles.
-Xlint
Enable detail about warnings.
-Xstdout
Redirect output of compilation run to a file.
-g
Add debug information to class files.
Notes
javac has traditionally accepted switches ( -source and -target ) that control the
version of the source language that the compiler would accept, and the version of
the class file format that was used for the outputted class files.
s d
m
P r o i l e s
This facility introduces additional compiler complexity (as multiple language syn‐
taxes must be supported internally) for some small developer benefit. In Java 8, this
capability has begun to be slightly tidied up and placed on a more formal basis.
From JDK 8 onward, javac will only accept source and target options from three
versions back. That is, only the formats from JDK 5, 6, 7, and 8 will be accepted by
javac . This does not affect the java interpreter—any class file from any Java version
will still work on the JVM shipped with Java 8.
C and C++ developers may find that the -g switch is less helpful to them than it is in
those other languages. This is largely due to the widespread use of IDEs in the Java
ecosystem—integrated debugging is simply a lot more useful, and easier to use, than
additional debug symbols in class files.
The use of the lint capability remains somewhat contraversial among developers.
Many Java developers produce code that triggers a large number of compilation
warnings, which they then simply ignore. However, experience on larger codebases
(especially on the JDK codebase itself ) suggests that in a substantial percentage of
cases, code that triggers warnings is code in which subtle bugs may lurk. Use of the
lint feature, or static analysis tools (such as FindBugs), is strongly recommended.
Search WWH ::




Custom Search