ECJ(1)
ecj β the eclipse JDT Batch Compiler π
okay so this manual page is for ecj, and the date on it is 13 March 2017. It's giving "Eclipse JDT Batch Compiler" and it's lowkey iconic. No cap. β¨
β¨ NAME β¨
ecj β the eclipse JDT Batch Compiler. That's the whole name, bestie. π
πΈ SYNOPSIS πΈ
ecj [OPTION]... [SOURCEFILE]... ...
π¦ DESCRIPTION π¦
So ecj is the batch compiler from Eclipse, and it's 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. Periodt. π«Ά
π OPTIONS SUMMARY π
Here's the summary of all the options, grouped by type. The explanations are in the OPTIONS section. Let's get into it. β¨
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.81.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>)*β it's the command-line form of anexportsstatement. It exports the package in source-module to the comma-separated list of *target-module*s. Slay. π--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 arequiresclause, equivalent to addingrequires source-modulein the target module'smodule-infofile. π«Ά--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.pathororg.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 theClass-Pathclauses 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. Iconic behaviour, fr fr. π₯-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.classfiles should be dumped. If it is omitted, no package directory structure is created. If you want to generate no.classfile 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 unitX.javalocated 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.classfile target setting. The possible values 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,5or5.0(major version: 49 minor: 0)1.6,6or6.0(major version: 50 minor: 0)1.7,7or7.0(major version: 51 minor: 0)1.8,8or8.0(major version: 52 minor: 0)1.9,9or9.0(major version: 53 minor: 0)
Defaults are:
1.1in-1.3mode1.2in-1.4mode1.5in-1.5mode1.6in-1.6mode1.7in-1.7mode1.8in-1.8mode1.9in-1.9mode
And btw: 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 values are:1.31.41.5,5or5.01.6,6or6.01.7,7or7.01.8,8or8.01.9,9or9.0
Defaults are:
1.3in-1.3mode1.3in-1.4mode1.5in-1.5mode1.6in-1.6mode1.7in-1.7mode1.8in-1.8mode1.9in-1.9mode
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 warnings
Examples:
warn:unusedLocal,deprecationβ enables only the given two warning options and disables all the other optionswarn:-unusedLocal,deprecation,+fallthroughβ disablesunusedLocalanddeprecation, enablesfallthrough, 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. π
+/-allDeadCodeβ dead code including trivialif (DEBUG)check+/-allDeprecationβ deprecation even inside deprecated code-allJavadocβ invalid or missing Javadoc-allOver-annβ all missing@Overrideannotations (superclass and superinterfaces)-all-static-methodβ all method can be declared as static warnings+assertIdentifierβ occurrence ofassertused as identifier-boxingβ autoboxing conversion+charConcatβ when a char array is used in a string concatenation without being converted explicitly to a string+compareIdenticalβ comparing identical expressions-conditionAssignβ possible accidental boolean assignment+constructorNameβ method with constructor name+deadCodeβ dead code excluding trivialif (DEBUG)check-dep-annβ missing@Deprecatedannotation+/-deprecationβ usage of deprecated type or member outside deprecated code+discouragedβ use of types matching a discouraged access rule-emptyBlockβ undocumented empty block
okay so the warning-token list keeps going, bestie β every single one, no skips, and the + / - / +/- markers stay exactly where they are π
+enumIdentifierβ occurrence of enum used as identifier β¨+enumSwitchβ incomplete enum switch π-enumSwitchPedanticβ report missing enum switch cases even in the presence of a default case π-fallthroughβ possible fall-through case-fieldHidingβ field hiding another variable+finalBoundβ type parameter with final bound+finallyβ finally block not completing normally+forbiddenβ use of types matching a forbidden access rule-hashCodeβ missing hashCode() method when overriding equals()+/-hidingβ macro for fieldHiding, localHiding, maskedCatchBlock, and typeHiding-includeAssertNullβ raise null warnings for variables that got tainted in an assert expression-indirectStaticβ indirect reference to static member-inheritNullAnnotβ consider null annotations as being inherited from an overridden method to any overriding methods+intfAnnotationβ annotation type used as super interface+intfNonInheritedβ interface non-inherited method compatibility-intfRedundantβ find redundant superinterfaces-invalidJavadocβ macro to toggle the 'malformed Javadoc comments' option and all its sub-options listed below-invalidJavadocTagβ report invalid Javadoc tags in Javadoc comments.-invalidJavadocTagDepβ report invalid deprecated references in Javadoc tag arguments-invalidJavadocTagNotVisibleβ report 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)-javadocβ invalid Javadoc-localHidingβ local variable hiding another variable+maskedCatchBlockβ hidden catch block-missingJavadocTagsβ macro to toggle the 'missing Javadoc tags' option and all its sub-options listed below-missingJavadocTagsMethodβ report missing Javadoc tags for a method's type parameters-missingJavadocTagsOverridingβ report missing Javadoc tags in overriding methods-missingJavadocTagsVisibility(<visibility>)β specify visibility modifier ("public", "protected" or "private") for missing Javadoc tags warnings. Usage example:missingJavadocTagsVisibility(public)-missingJavadocCommentsβ macro to toggle the 'missing Javadoc comments' option and all its sub-options listed below-missingJavadocCommentsOverridingβ report missing Javadoc comments in overriding methods-missingJavadocCommentsVisibility(<visibility>)β specify visibility modifier ("public", "protected" or "private") for missing Javadoc comments warnings. Usage example:missingJavadocCommentsVisibility(public)-nlsβ non-nls string literals (lacking of tags//$NON-NLS-<n>)+noEffectAssignβ assignment with no effect+nonnullNotRepeatedβ nonnull parameter annotation from overridden method is not repeated in an overriding method. Is effective only with thenullAnnotoption enabled.+/-nullβ potential missing or redundant null check-nullAnnotβ enable 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
-nullAnnotConflictβ report conflicts between null annotation specified and nullness inferred. Is effective only with thenullAnnotoption enabled.-nullAnnotRedundantβ report redundant specification of null annotation. Is effective only with thenullAnnotoption enabled.-nullDereferenceβ missing null check-nullUncheckedConversionβ report unchecked conversion from unannotated type to@NonNulltype. Is effective only with thenullAnnotoption enabled.
-over-annβ missing@Overrideannotation (superclass only)-paramAssignβ assignment to a parameter+pkgDefaultMethodβ attempt to override package-default method+rawβ usage a of raw type (instead of a parameterized type)+/-resourceβ (potentially) unsafe usage of resource of type Closeable-semicolonβ unnecessary semicolon or empty statement+serialβ missing serialVersionUID-specialParamHidingβ constructor or setter parameter hiding another field+/-static-accessβ macro for indirectStatic and staticReceiver-static-methodβ an instance method that could be as a static method+staticReceiverβ if a non static receiver is used to get a static field or call a static method-superβ overriding a method without making a super invocation+suppressβ enable@SuppressWarnings-switchDefaultβ switch statement lacking a default case-syncOverrideβ missing synchronized in synchronized method override-syntacticAnalysisβ perform syntax-based null analysis for fields-syntheticAccessβ when performing synthetic access for innerclass-tasksβ enable support for tasks tags in source code+typeHidingβ type parameter hiding another type+unavoidableGenericProblemsβ report even unavoidable type safety problems due to raw APIs+uncheckedβ unchecked type operation-unnecessaryElseβ unnecessary else clause-unqualifiedFieldβ unqualified reference to field+/-unusedβ macro for unusedImport, unusedLabel, unusedLocal, unusedPrivate, unusedThrown, unusedTypeArgs, and unusedTypeParameter-unusedAllocationβ allocating an object that is not used-unusedArgumentβ unused method parameter (deprecated option; use unusedParam instead)+unusedImportβ unused import reference+unusedLabelβ unused label+unusedLocalβ unused local variable+unusedParamβ unused method parameter+unusedParamImplementingβ unused parameter for implementing method+unusedParamIncludeDocβ unused parameter documented in a Javadoc comment tag+unusedParamOverridingβ unused parameter for overriding method+unusedPrivateβ unused private member declaration-unusedThrownβ unused declared thrown exception-unusedThrownIncludeDocCommentβ unused declared thrown exception documented in a Javadoc comment tag-unusedThrownExemptExceptionThrowableβ report unused declared thrown exception but exempt Exception and Throwable-unusedThrownWhenOverridingβ unused declared thrown exception in overriding method+unusedTypeArgsβ unused type arguments for method and constructor+unusedTypeParameterβ unused type parameter-uselessTypeCheckβ unnecessary cast/instanceof operation+varargsCastβ varargs argument need explicit cast+/-warningTokenβ unhandled 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:
-gdefault changed to all enabled-preserveAllLocalsdefault changed to enabled-enableJavadocdefault changed to enablederror/warning forbiddendefault 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β okay bestie, this one is literally asking the compiler to preserve info about a method's formal parameters (like their names, periodt) so reflection libraries, annotation processing, code weaving, and the debugger can all access it. This option is supported from target level1.8and later. Also: annotation processing options (require a1.6VM or above and are used only if the compliance is1.6).
β¨ Annotation Processing Options β¨
-Akey[=value]β Annotation processors options that are passed to annotation processors.keyis made of identifiers separated by dots.-proc:[only|none]β If-proc:onlyis specified, the annotation processors will run but no compilation will be performed. If-proc:noneis 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:nonemay 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.-Xemacsis not ignored.-Xβ Print non-standard options and exit.-Oβ Optimize for execution time.
π Advanced Options π
@<file>β Read command-line arguments fromfile.-maxProblems <n>β Max number of problems per compilation unit (100by 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.classfiles 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-logmode).-timeβ Display speed information.-noExitβ Do not callSystem.exit(n)at end of compilation (n=0if 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 nameCLASSPATHwill 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.
π SEE ALSO π
<http://help.eclipse.org/topic/org.eclipse.jdt.doc.user/tasks/task-using_batch_compiler.htm>
π BUGS π
To report bugs, use <https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT&component=Core>
π AUTHOR π
For details on Eclipse committers, see <http://www.eclipse.org/committers/>
π and that's the ecj(13 March 2017) manual page, bestie β now go forth and compile something iconic π
π¦ where this page comes from
- centos-stream 10: ecj 1:4.23-11.el10 Β· EPL-2.0
- centos-stream 9: ecj 1:4.20-18.el9 Β· EPL-2.0
- fedora 43: ecj 1:4.23-14.fc43 Β· EPL-2.0
- fedora 44: ecj 1:4.23-15.fc44 Β· EPL-2.0
- opensuse-leap 16.0: ecj 4.23-160000.2.2 Β· EPL-2.0 AND GPL-2.0-only WITH Classpath-exception-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms