ecj1
The eclipse jdt batch compiler
Usage
ecj [OPTION] ...
[SOURCEFILE] ... ...
Overview
ecj is the batch compiler from Eclipse and is available as ecj.jar. Since 3.3, this jar also contains the support for jsr199 (Compiler API) and the support for jsr269 (Annotation processing). In order to use the annotations processing support, a 1.6 VM is required.
Options summary
Here is a summary of all the options, grouped by type. Explanations are in the OPTIONS section.
Module Options
--add-exports --add-modules --add-reads --limit-modules -p|--module-path --module-source-path --processor-module-path --system
ClassPath Options
-bootclasspath -cp|-classpath -extdirs -endorseddirs -sourcepath -d -encoding
Compliance Options
-target -1.3 -1.4 -1.5 -1.6 -1.7 -1.8 1.9 -source --release
Warning Options
-?:warn -help:warn -warn:... -nowarn -err:... -deprecation -properties
Debug Options
-g -preserveAllLocals -parameters
Annotation Processing Options
-Akey[=value] -proc:[only|none] -processor -processorpath -s -XprintProcessorInfo -XprintRounds -classNames
Ignored Options (for compatibility with javac options)
-J -X -O
Advanced Options
@<file> -maxProblems -log -Xemacs -proceedOnError -verbose -referenceInfo -progress -time -noExit -repeat -inlineJSR -enableJavaDoc -missingNullDefault
Helping Options
-? -help -v -version -showversion
Options
Module Options (Supported from 9 onwards)
-
--add-exports <source-module>/<package>=<target-module>(,<target-module>)* -
A command line form of exports statement which exports the package in source-module to the comma separated list of target modules.
- --add-modules <module 1>,<module 2>,...,<module P>
-
Extend the default set of root modules with a list of comma separated modules.
-
--add-reads <source-module>=<target-module> -
A command line form of a requires clause equivalent to adding requires source-module in target modules module-info file.
- --limit-modules <module 1>,<module 2>,...,<module P>
-
Limit the observable modules to the list of comma separated modules.
- -p|--module-path <dir 1>;<dir 2>;...;<dir P>
-
This is a list of directories where application modules can be found. Entries are separated by the platform path separator.
- --module-source-path <dir 1>;<dir 2>;...;<dir P>
-
This is a list of directories where source files for modules can be found. Entries are separated by the platform path separator.
-
--processor-module-path <path> -
module path where annotation processors can be found.
-
--system <jdk> -
Override location of system modules.
ClassPath Options
- -bootclasspath <dir 1>;<dir 2>;...;<dir P>
-
This is a list of directories or jar files used to bootstrap the class files used by the compiler. By default the libraries of the running VM are used. Entries are separated by the platform path separator. Each directory or file can specify access rules for types between '[' and ']'. If no bootclasspath is specified, the compiler will infer it using the following system properties sun.boot.class.path, vm.boot.class.path or org.apache.harmony.boot.class.path in this order respectively
- -cp|-classpath <dir 1>;dir2;...<dir P>
-
This is a list of directories or jar files used to compile the source files. The default value is the value of the property "java.class.path". Entries are separated by the platform path separator. Each directory or file can specify access rules for types between '[' and ']' (e.g. [-X] to forbid access to type X, [~X] to discourage access to type X, [+p/X:-p/*] to forbid access to all types in package p but allow access to p/X). The compiler follows the Class-Path clauses of jar files' manifests recursively and appends each referenced jar file to the end of the classpath, provided it is not on the classpath yet.
- -extdirs <dir 1>;<dir 2>;...;<dir P>
-
This is a list of directories used to specify the location of extension zip/jar files. Entries are separated by the platform path separator.
- -endorseddirs <dir 1>;<dir 2>;...;<dir P>
-
This is a list of directories used to specify the location of endorsed zip/jar files. Entries are separated by the platform path separator.
- -sourcepath <dir 1>;<dir 2>;...;<dir P>
-
This is a list of directories used to specify the source files. Entries are separated by the platform path separator. Each directory can specify access rules for types between '[' and ']'.
- -d <dir 1>|none
-
This is used to specify in which directory the generated .class files should be dumped. If it is omitted, no package directory structure is created. If you want to generate no .class file at all, use -d none.
- -encoding <encoding name>
-
Specify default encoding for all source files. Custom encoding can also be specified on a per file basis by suffixing each input source file/folder name with [<encoding name>]. For example X.java[UTF-8] would specify the UTF-8 encoding for the compilation unit X.java located in the current user directory. If multiple default source file encodings are specified, the last one will be used.
For example: ... -encoding UTF-8 X.java[Cp1252] Y.java[UTF-16] Z.java ....
All source files will be read using UTF-8 encoding (this includes Z.java). X.java will be read using Cp1252 encoding and Y.java will be read using UTF-16 encoding.... -encoding UTF-8 -encoding UTF-16 ....
All source files will be read using UTF-16 encoding. The -encoding option for UTF-8 is ignored.... -encoding Cp1252 /foo/bar/X.java[UTF-16] /foo/bar[UTF-8] ....
All source files will be read using Cp1252 encoding. X.java is the only file inside the /foo/bar directory to be read using the encoding UTF-16. All other files in that directory will use UTF-8 encoding.
Compliance Options
- -target 1.1 to 1.9 (or 9, 9.0, etc.)
-
This specifies the .class file target setting. The possible value are:
1.1(major version: 45 minor: 3)
1.2(major version: 46 minor: 0)
1.3(major version: 47 minor: 0)
1.4(major version: 48 minor: 0)
1.5, 5 or 5.0 (major version: 49 minor: 0)
1.6, 6 or 6.0 (major version: 50 minor: 0)
1.7, 7 or 7.0 (major version: 51 minor: 0)
1.8, 8 or 8.0 (major version: 52 minor: 0)
1.9, 9 or 9.0 (major version: 53 minor: 0)Defaults are:
1.1 in -1.3 mode
1.2 in -1.4 mode
1.5 in -1.5 mode
1.6 in -1.6 mode
1.7 in -1.7 mode
1.8 in -1.8 mode
1.9 in -1.9 mode clcd1.1 can be used to generate the StackMap attribute.
-
-1.3 -
Set compliance level to 1.3. Implicit -source 1.3 -target 1.1.
-
-1.4 -
Set compliance level to 1.4 (default). Implicit -source 1.3 -target 1.2.
-
-1.5 -
Set compliance level to 1.5. Implicit -source 1.5 -target 1.5.
-
-1.6 -
Set compliance level to 1.6. Implicit -source 1.6 -target 1.6.
-
-1.7 -
Set compliance level to 1.7. Implicit -source 1.7 -target 1.7.
-
-1.8 -
Set compliance level to 1.8. Implicit -source 1.8 -target 1.8.
-
-1.9 -
Set compliance level to 1.9. Implicit -source 1.9-target 1.9.
- -source 1.1 to 1.9 (or 9, 9.0, etc.)
-
This is used to specify the source level expected by the compiler. The possible value are:
1.3
1.4
1.5, 5 or 5.0
1.6, 6 or 6.0
1.7, 7 or 7.0
1.8, 8 or 8.0
1.9, 9 or 9.0Defaults are:
1.3 in -1.3 mode
1.3 in -1.4 mode
1.5 in -1.5 mode
1.6 in -1.6 mode
1.7 in -1.7 mode
1.8 in -1.8 mode
1.9 in -1.9 mode
In 1.4, assert is treated as a keyword. In 1.5 and 1.6, enum and assert are treated as keywords.
-
--release N -
Compile for a specific VM version. Used for compiling against older APIs.
Warning Options
- -?:warn -help:warn
-
Display advanced warning options
- -warn:...
-
Specify the set of enabled warnings.
-warn:none disable all warnings
-warn:<warning tokens separated by ,> enable exactly the listed warnings
-warn:+<warning tokens separated by ,> enable additional warnings
-warn:-<warning tokens separated by ,> disable specific warningsExamples:enables only the given two warning options and disables all the other options
disables unusedLocal and deprecation, enables fallthrough, and leaves the other warning options untouched
The first column below shows the default state for an option. A mark "+/-" indicates that an option covers several fine grained warning variants, some of which are enabled by default, others disabled. This means that specifying the given option with "+" will enable more warnings than the default, and specifying "-" disables some that are enabled by default.
+/-
allDeadCodedead code including trivial if (DEBUG) check+/-
allDeprecationdeprecation even inside deprecated code-
allJavadocinvalid or missing Javadoc-
allOver-annall missing @Override annotations (superclass and superinterfaces)-
all-static-methodall method can be declared as static warnings+
assertIdentifieroccurrence of assert used as identifier-
boxingautoboxing conversion+
charConcatwhen a char array is used in a string concatenation without being converted explicitly to a string+
compareIdenticalcomparing identical expressions-
conditionAssignpossible accidental boolean assignment+
constructorNamemethod with constructor name+
deadCodedead code excluding trivial if (DEBUG) check-
dep-annmissing @Deprecated annotation+/-
deprecationusage of deprecated type or member outside deprecated code+
discourageduse of types matching a discouraged access rule-
emptyBlockundocumented empty block+
enumIdentifieroccurrence of enum used as identifier+
enumSwitchincomplete enum switch-
enumSwitchPedanticreport missing enum switch cases even in the presence of a default case-
fallthroughpossible fall-through case-
fieldHidingfield hiding another variable+
finalBoundtype parameter with final bound+
finallyfinally block not completing normally+
forbiddenuse of types matching a forbidden access rule-
hashCodemissing hashCode() method when overriding equals()+/-
hidingmacro for fieldHiding, localHiding, maskedCatchBlock, and typeHiding-
includeAssertNullraise null warnings for variables that got tainted in an assert expression-
indirectStaticindirect reference to static member-
inheritNullAnnotconsider null annotations as being inherited from an overridden method to any overriding methods+
intfAnnotationannotation type used as super interface+
intfNonInheritedinterface non-inherited method compatibility-
intfRedundantfind redundant superinterfaces-
invalidJavadocmacro to toggle the 'malformed Javadoc comments' option and all its sub-options listed below-
invalidJavadocTagreport invalid Javadoc tags in Javadoc comments.-
invalidJavadocTagDepreport invalid deprecated references in Javadoc tag arguments-
invalidJavadocTagNotVisiblereport invalid non-visible references in Javadoc tag arguments-
invalidJavadocVisibility(<visibility>)specify visibility modifier ("public", "protected" or "private") for malformed Javadoc tag warnings. Usage example: invalidJavadocVisibility(public)-
javadocinvalid Javadoc-
localHidinglocal variable hiding another variable+
maskedCatchBlockhidden catch block-
missingJavadocTagsmacro to toggle the 'missing Javadoc tags' option and all its sub-options listed below-
missingJavadocTagsMethodreport missing Javadoc tags for a method's type parameters-
missingJavadocTagsOverridingreport missing Javadoc tags in overriding methods-
missingJavadocTagsVisibility(<visibility>)specify visibility modifier ("public", "protected" or "private") for missing Javadoc tags warnings. Usage example: missingJavadocTagsVisibility(public)-
missingJavadocCommentsmacro to toggle the 'missing Javadoc comments' option and all its sub-options listed below-
missingJavadocCommentsOverridingreport missing Javadoc comments in overriding methods-
missingJavadocCommentsVisibility(<visibility>)specify visibility modifier ("public", "protected" or "private") for missing Javadoc comments warnings. Usage example: missingJavadocCommentsVisibility(public)-
nlsnon-nls string literals (lacking of tags //$NON-NLS-<n>)+
noEffectAssignassignment with no effect+
nonnullNotRepeatednonnull parameter annotation from overridden method is not repeated in an overriding method. Is effective only with the nullAnnot option enabled.+/-
nullpotential missing or redundant null check-
nullAnnotenable annotation based null analysis. If desired, the annotation types to be interpreted by the compiler can be specified by appending (nullable|nonnull|nonnullbydefault), where each annotation type is specified using its fully qualified name. Usage example: nullAnnot(p.Nullable|p.NonNull|p.NonNullByDefault)Enabling this option enables all null-annotation related sub-options. These can be individually controlled using options listed below
-
nullAnnotConflictreport conflicts between null annotation specified and nullness inferred. Is effective only with the nullAnnot option enabled.-
nullAnnotRedundantreport redundant specification of null annotation. Is effective only with the nullAnnot option enabled.-
nullDereferencemissing null check-
nullUncheckedConversionreport unchecked conversion from unannotated type to @NonNull type. Is effective only with the nullAnnot option enabled.-
over-annmissing @Override annotation (superclass only)-
paramAssignassignment to a parameter+
pkgDefaultMethodattempt to override package-default method+
rawusage a of raw type (instead of a parameterized type)+/-
resource(potentially) unsafe usage of resource of type Closeable-
semicolonunnecessary semicolon or empty statement+
serialmissing serialVersionUID-
specialParamHidingconstructor or setter parameter hiding another field+/-
static-accessmacro for indirectStatic and staticReceiver-
static-methodan instance method that could be as a static method+
staticReceiverif a non static receiver is used to get a static field or call a static method-
superoverriding a method without making a super invocation+
suppressenable @SuppressWarnings-
switchDefaultswitch statement lacking a default case-
syncOverridemissing synchronized in synchronized method override-
syntacticAnalysisperform syntax-based null analysis for fields-
syntheticAccesswhen performing synthetic access for innerclass-
tasksenable support for tasks tags in source code+
typeHidingtype parameter hiding another type+
unavoidableGenericProblemsreport even unavoidable type safety problems due to raw APIs+
uncheckedunchecked type operation-
unnecessaryElseunnecessary else clause-
unqualifiedFieldunqualified reference to field+/-
unusedmacro for unusedImport, unusedLabel, unusedLocal, unusedPrivate, unusedThrown, unusedTypeArgs, and unusedTypeParameter-
unusedAllocationallocating an object that is not used-
unusedArgumentunused method parameter (deprecated option; use unusedParam instead)+
unusedImportunused import reference+
unusedLabelunused label+
unusedLocalunused local variable+
unusedParamunused method parameter+
unusedParamImplementingunused parameter for implementing method+
unusedParamIncludeDocunused parameter documented in a Javadoc comment tag+
unusedParamOverridingunused parameter for overriding method+
unusedPrivateunused private member declaration-
unusedThrownunused declared thrown exception-
unusedThrownIncludeDocCommentunused declared thrown exception documented in a Javadoc comment tag-
unusedThrownExemptExceptionThrowablereport unused declared thrown exception but exempt Exception and Throwable-
unusedThrownWhenOverridingunused declared thrown exception in overriding method+
unusedTypeArgsunused type arguments for method and constructor+
unusedTypeParameterunused type parameter-
uselessTypeCheckunnecessary cast/instanceof operation+
varargsCastvarargs argument need explicit cast+/-
warningTokenunhandled or unused warning token in @SuppressWarnings
-
-nowarn -
No warning (equivalent to -warn:none)
- -err:...
-
Specify the set of enabled warnings that are converted to errors.
E.g.
-err:unusedLocal,deprecation
unusedLocal and deprecation warnings will be converted to errors. All other warnings are still reported as warnings.-err:<warning tokens separated by ,> convert exactly the listed warnings to errors
-err:+<warning tokens separated by ,> convert additional warnings to errors
-err:-<warning tokens separated by ,> remove specific warnings from being converted to errors
-
-deprecation -
Equivalent to -warn:+deprecation.
-
-properties <file> -
Set warnings/errors option based on the properties file contents. This option can be used with -nowarn, -err:.. or -warn:.. options, but the last one on the command line sets the options to be used.
The properties file contents can be generated by setting project specific settings on an existing java project and using the file in .settings/org.eclipse.jdt.core.prefs file as a properties file, or a simple text file that is defined entry/value pairs using the constants defined in the org.eclipse.jdt.core.JavaCore class. Of those constants declared in this class, all options starting with "org.eclipse.jdt.core.compiler." are interpreted by the batch compiler.
...
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
...To ensure that a property file has the same effect when used in the IDE and for the batch compiler, use of the -properties option will change the defaults for a few options:
-g default changed to all enabled
-preserveAllLocals default changed to enabled
-enableJavadoc default changed to enabled
error/warning forbidden default changed to error
Debug Options
-
-g[:none|:lines,vars,source] -
Set the debug attributes level
-g All debug info (equivalent to -g:lines,vars,source)
-g:none No debug info
-g:[lines,vars,source] Selective debug info
Not specifying this option is equivalent to setting -g:lines,source.
-
-preserveAllLocals -
Explicitly request the compiler to preserve all local variables (for debug purpose). If omitted, the compiler will remove unused locals.
-
-parameters -
Explicitly request the compiler to preserve information about the formal parameters of a method (such as their names) to be accessed from reflection libraries, annotation processing, code weaving, and in the debugger. This option is supported from target level 1.8 and later. Annotation processing options (require a 1.6 VM or above and are used only if the compliance is 1.6)
Annotation Processing Options
-
-Akey[=value] -
Annotation processors options that are passed to annotation processors. key is made of identifiers separated by dots
- -proc:[only|none]
-
If -proc:only is specified, the annotation processors will run but no compilation will be performed. If -proc:none is specified, annotation processors will not be discovered or run; compilation will proceed as if no annotation processors were found. By default the compiler must search the classpath for annotation processors, so specifying -proc:none may speed compilation if annotation processing is not required.
-
-processor <class1[,class2,...]> -
Qualified class names of annotation processors to run. If specified, the normal processor discovery process will be skipped.
- -processorpath <dir 1>;<dir 2>;...;<dir P>
-
A list of directories or jar files which will be searched for annotation processors. Entries are separated by the platform path separator. If not specified, the classpath will be searched instead.
-
-s <dir> -
The directory where generated source files will be created.
-
-XprintProcessorInfo -
Print information about which annotations and which elements a processor is asked to process
-
-XprintRounds -
Print information about annotation processing rounds
-
-classNames <class1[,class2,...]> -
Qualified names of binary types that need to be processed
Ignored Options (for compatibility with javac options)
-J<option>
|
Pass option to the virtual machine |
|---|---|
-X<option>
|
Specify non-standard option. -Xemacs is not ignored. |
-
-X -
Print non-standard options and exit
-
-O -
Optimize for execution time
Advanced Options
- @<file>
-
Read command-line arguments from file
-
-maxProblems <n> -
Max number of problems per compilation unit (100 by default)
-
-log <filename> -
Specify a log file in which all output from the compiler will be dumped. This is really useful if you want to debug the batch compiler or get a file which contains all errors and warnings from a batch build. If the extension is .xml, the generated log will be an xml file.
-
-genericsignature -
Explicitly request the compiler to preserve information about generic signature of lambda expressions.
-
-Xemacs -
Use emacs style to present errors and warnings locations into the console and regular text logs. XML logs are unaffected by this option. With this option active, the message:
2. WARNING in /workspace/X.java
(at line 8)...
is presented as:
/workspace/X.java:8: warning: The method...
-
-proceedOnError[:Fatal] -
Keep compiling in spite of errors, dumping class files with problem methods or problem types. This is recommended only if you want to be able to run your application even if you have remaining errors. With ":Fatal", all optional errors are treated as fatal and this leads to code that will abort if an error is reached at runtime. Without ":Fatal", optional errors don't prevent the proper code generation and the produced .class files can be run without a problem.
-
-verbose -
Print accessed/processed compilation units in the console or the log file if specified.
-
-referenceInfo -
Compute reference info. This is useful only if connected to the builder. The reference infos are useless otherwise.
-
-progress -
Show progress (only in -log mode).
-
-time -
Display speed information.
-
-noExit -
Do not call System.exit(n) at end of compilation (n=0 if no error).
-
-repeat <n> -
Repeat compilation process <n> times (perf analysis).
-
-inlineJSR -
Inline JSR bytecode (implicit if target >= 1.5).
-
-enableJavadoc -
Consider references inside Javadoc. The Javadoc options are effective only when this option is enabled.
-
-missingNullDefault -
When annotation based null analysis is enabled (using "nullAnnot", above), this option will raise a warning whenever there is no default annotation on a package or a type.
-
-annotationpath -
When annotation based null analysis is enabled (using "nullAnnot", above), this option defines locations where to find external annotations to support annotation-based null analysis. The value of this options is a list of directories or zip files. Entries are separated by the platform path separator. The special name CLASSPATH will cause lookup of external annotations from the classpath and sourcepath.
Helping Options
-
-? -help -
Display the help message.
-
-v -version -
Display the build number of the compiler. This is very useful to report a bug.
-
-showversion -
Display the build number of the compiler and continue. This is very useful to report a bug.
Releases
9 releases since Debian 5.0 (Lenny); the text changed 2 times.
--add-exports since Debian 10 (Buster);
--add-reads since Debian 10 (Buster);
--processor-module-path since Debian 10 (Buster);
--release since Debian 10 (Buster);
--system since Debian 10 (Buster);
-1.3 since Debian 10 (Buster);
-1.4 since Debian 10 (Buster);
-1.5 since Debian 10 (Buster);
-1.6 since Debian 10 (Buster);
-1.7 since Debian 10 (Buster);
-1.8 since Debian 10 (Buster);
-1.9 since Debian 10 (Buster);
-? since Debian 10 (Buster);
-Akey since Debian 10 (Buster);
-O since Debian 10 (Buster);
-X since Debian 10 (Buster);
-Xemacs since Debian 10 (Buster);
-XprintProcessorInfo since Debian 10 (Buster);
-XprintRounds since Debian 10 (Buster);
-annotationpath since Debian 10 (Buster);
-classNames since Debian 10 (Buster);
-deprecation since Debian 10 (Buster);
-enableJavadoc since Debian 10 (Buster);
-genericsignature since Debian 10 (Buster);
-help since Debian 10 (Buster);
-inlineJSR since Debian 10 (Buster);
-log since Debian 10 (Buster);
-maxProblems since Debian 10 (Buster);
-missingNullDefault since Debian 10 (Buster);
-noExit since Debian 10 (Buster);
-nowarn since Debian 10 (Buster);
-parameters since Debian 10 (Buster);
-preserveAllLocals since Debian 10 (Buster);
-proceedOnError since Debian 10 (Buster);
-processor since Debian 10 (Buster);
-progress since Debian 10 (Buster);
-properties since Debian 10 (Buster);
-referenceInfo since Debian 10 (Buster);
-repeat since Debian 10 (Buster);
-s since Debian 10 (Buster);
-showversion since Debian 10 (Buster);
-time since Debian 10 (Buster);
-v since Debian 10 (Buster);
-verbose since Debian 10 (Buster);
-version since Debian 10 (Buster).
-d until Debian 9 (Stretch).