JDT Core options

JDT Core options control the behavior of core features such as the Java compiler, code formatter, code assist, and other core behaviors.  The APIs for accessing the options are defined in JavaCore.  Options can be accessed as a group as follows:

Options can also be accessed individually by a string name.

Options are stored as a hashtable of all known configurable options with their values. Helper constants have been defined on JavaCore for each option ID and its possible constant values.

The following code fragment restores the value of all core options to their defaults except for one (COMPILER_PB_DEPRECATION), which is set specifically.

   // Get the current options
   Hashtable options = JavaCore.getDefaultOptions();
   
   // Change the value of an option
   options.put(JavaCore.COMPILER_PB_DEPRECATION, JavaCore.ERROR);
   
   // Set the new options
   JavaCore.setOptions(options);
The following code fragment keeps the value of the current options and modifies only one (COMPILER_PB_DEPRECATION):
   // Get the current options
   Hashtable options = JavaCore.getOptions();
   
   // Change the value of an option
   options.put(JavaCore.COMPILER_PB_DEPRECATION, JavaCore.ERROR);
   
   // Set the new options
   JavaCore.setOptions(options);

Project specific options

The values of options can be overridden per project using protocol in IJavaProject.

The following code fragment retrieves the value of an option (COMPILER_PB_DEPRECATION) for a specific project in two different ways.  The boolean parameter controls whether only the project-specific options should be returned in a query or whether the project's option values should be merged with the values in JavaCore.

   // Get the project
   IJavaProject project = ...;

   // See if the value of an option has been set in this project
   String value = project.getOption(JavaCore.COMPILER_PB_DEPRECATION, false);
   if (value == null) {
     // no specific option was set on the project
     ...
   }
   
   // Get the value of an option from this project.  Use the value from 
   // JavaCore value if none is specified for the project
   String value = project.getOption(JavaCore.COMPILER_PB_DEPRECATION, true);

Major change in default JDT Core 3.0 options

Default compliance level has been changed. Now default compliance level is 1.4 instead of 1.3 and default target platform is 1.2 instead of 1.1.

JDT Core options descriptions

The following tables describe the available JDT Core options.  The option id is shown in parentheses and the default value is shown in bold italics.

Options categories

Compiler options

Description Values
Generating Local Variable Debug Attribute (COMPILER_LOCAL_VARIABLE_ATTR)
When generated, this attribute will enable local variable names to be displayed in the debugger, only in places where variables are definitely assigned (.class file is then bigger) GENERATE
DO_NOT_GENERATE
Generating Line Number Debug Attribute (COMPILER_LINE_NUMBER_ATTR)
When generated, this attribute will enable source code highlighting in the debugger (.class file is then bigger). GENERATE
DO_NOT_GENERATE
Generating Source Debug Attribute (COMPILER_SOURCE_FILE_ATTR)
When generated, this attribute will enable the debugger to present the corresponding source code. GENERATE
DO_NOT_GENERATE
Preserving Unused Local Variables (COMPILER_CODEGEN_UNUSED_LOCAL)
Unless requested to preserve unused local variables (i.e. never read), the compiler will optimize them out, potentially altering debugging. PRESERVE
OPTIMIZE_OUT
Defining Target Java Platform (COMPILER_CODEGEN_TARGET_PLATFORM)
For binary compatibility reason, .class files can be tagged with certain VM versions and later. Note that the "1.4" target requires you to toggle the compliance mode to "1.4" also. VERSION_1_1
VERSION_1_2
VERSION_1_3
VERSION_1_4
Inline JSR Bytecode Instruction (COMPILER_CODEGEN_INLINE_JSR_BYTECODE)
When enabled, the compiler will no longer generate JSR instructions, but rather inline corresponding subroutine code sequences (mostly corresponding to try finally blocks). The generated code will thus get bigger, but will load faster on virtual machines since the verification process is then much simpler. This mode is anticipating support for the Java Specification Request 202. ENABLED
DISABLED
Javadoc Comment Support (COMPILER_DOC_COMMENT_SUPPORT)
When this support is disabled, the compiler will ignore all javadoc problems options settings and will not report any javadoc problem. It will also not find any reference in javadoc comment and DOM AST Javadoc node will be only a flat text instead of having structured tag elements. ENABLED
DISABLED
Reporting Unreachable Code (COMPILER_PB_UNREACHABLE_CODE)
Unreachable code can optionally be reported as an error, warning or simply ignored. The bytecode generation will always optimize it out. ERROR
WARNING
IGNORE
Reporting Invalid Import (COMPILER_PB_INVALID_IMPORT)
An import statement that cannot be resolved might optionally be reported as an error, as a warning or ignored. ERROR
WARNING
IGNORE
Reporting Attempt to Override Package-Default Method (COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD)
A package default method is not visible in a different package, and thus cannot be overridden. When enabling this option, the compiler will signal such scenarii either as an error or a warning. ERROR
WARNING
IGNORE
Reporting Method With Constructor Name (COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME)
Naming a method with a constructor name is generally considered poor style programming. When enabling this option, the compiler will signal such scenarii either as an error or a warning. ERROR
WARNING
IGNORE
Reporting Deprecation (COMPILER_PB_DEPRECATION)
When enabled, the compiler will signal use of deprecated API either as an error or a warning. ERROR
WARNING
IGNORE
Reporting Deprecation Inside Deprecated Code (COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE)
When enabled, the compiler will signal use of deprecated API either as an error or a warning. ENABLED
DISABLED
Reporting Deprecation When Overriding Deprecated Method (COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD)
When enabled, the compiler will signal the declaration of a method overriding a deprecated one. ENABLED
DISABLED
Reporting Hidden Catch Block (COMPILER_PB_HIDDEN_CATCH_BLOCK)
Local to a try statement, some catch blocks may hide others , e.g.
   try {
      throw new java.io.CharConversionException();
   } catch (java.io.CharConversionException e) {
   } catch (java.io.IOException e) {}.
When enabling this option, the compiler will issue an error or a warning for hidden catch blocks corresponding to checked exceptions
ERROR
WARNING
IGNORE
Reporting Unused Local (COMPILER_PB_UNUSED_LOCAL)
When enabled, the compiler will issue an error or a warning for unused local variables (i.e. variables never read from) ERROR
WARNING
IGNORE
Reporting Unused Parameter (COMPILER_PB_UNUSED_PARAMETER)
When enabled, the compiler will issue an error or a warning for unused method parameters (i.e. parameters never read from) ERROR
WARNING
IGNORE
Reporting Unused Parameter if Implementing Abstract Method (COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT)
When enabled, the compiler will signal unused parameters in abstract method implementations. ENABLED
DISABLED
Reporting Unused Parameter if Overriding Concrete Method (COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE)
When enabled, the compiler will signal unused parameters in methods overriding concrete ones. ENABLED
DISABLED
Reporting Unused Import (COMPILER_PB_UNUSED_IMPORT)
When enabled, the compiler will issue an error or a warning for unused import reference ERROR
WARNING
IGNORE
Reporting Unused Private Members (COMPILER_PB_UNUSED_PRIVATE_MEMBER)
When enabled, the compiler will issue an error or a warning whenever a private method or field is declared but never used within the same unit. ERROR
WARNING
IGNORE
Reporting Synthetic Access Emulation (COMPILER_PB_SYNTHETIC_ACCESS_EMULATION)
When enabled, the compiler will issue an error or a warning whenever it emulates access to a non-accessible member of an enclosing type. Such access can have performance implications. ERROR
WARNING
IGNORE
Reporting Non-Externalized String Literal (COMPILER_PB_NON_NLS_STRING_LITERAL)
When enabled, the compiler will issue an error or a warning for non externalized String literal (i.e. non tagged with //$NON-NLS-<n>$) ERROR
WARNING
IGNORE
Reporting Usage of 'assert' Identifier (COMPILER_PB_ASSERT_IDENTIFIER)
When enabled, the compiler will issue an error or a warning whenever 'assert' is used as an identifier (reserved keyword in 1.4) ERROR
WARNING
IGNORE
Reporting Non-Static Reference to a Static Member (COMPILER_PB_STATIC_ACCESS_RECEIVER)
When enabled, the compiler will issue an error or a warning whenever a static field or method is accessed with an expression receiver. ERROR
WARNING
IGNORE
Reporting Indirect Reference to a Static Member (COMPILER_PB_INDIRECT_STATIC_ACCESS)
When enabled, the compiler will issue an error or a warning whenever a static field or method is accessed in an indirect way. A reference to a static member should preferably be qualified with its declaring type name. ERROR
WARNING>
IGNORE
Reporting Assignment with No Effect (COMPILER_PB_NO_EFFECT_ASSIGNMENT)
When enabled, the compiler will issue an error or a warning whenever an assignment has no effect (e.g. 'x = x'). ERROR
WARNING
IGNORE
Reporting Empty Statements and Unnecessary Semicolons (COMPILER_PB_EMPTY_STATEMENT)
When enabled, the compiler will issue an error or a warning if an empty statement or a unnecessary semicolon is encountered. ERROR
WARNING
IGNORE
Reporting Unnecessary Type Check (COMPILER_PB_UNNECESSARY_TYPE_CHECK)
When enabled, the compiler will issue an error or a warning when a cast or an instanceof operation is unnecessary. ERROR
WARNING
IGNORE
Reporting Unnecessary Else (COMPILER_PB_UNNECESSARY_ELSE)
When enabled, the compiler will issue an error or a warning when a statement is unnecessarily nested within an else clause (in situation where then clause is not completing normally). ERROR
WARNING
IGNORE
Reporting Interface Method not Compatible with non-Inherited Methods (COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD)
When enabled, the compiler will issue an error or a warning whenever an interface defines a method incompatible with a non-inherited Object one. ERROR
WARNING
IGNORE
Reporting Usage of char[] Expressions in String Concatenations (COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION)
When enabled, the compiler will issue an error or a warning whenever a char[] expression is used in String concatenations (e.g. "hello" + new char[]{'w','o','r','l','d'}), ERROR
WARNING
IGNORE
Reporting Local Variable Declaration Hiding another Variable (COMPILER_PB_LOCAL_VARIABLE_HIDING)
When enabled, the compiler will issue an error or a warning whenever a local variable declaration is hiding some field or local variable (either locally, inherited or defined in enclosing type). ERROR
WARNING
IGNORE
Reporting Field Declaration Hiding another Variable (COMPILER_PB_FIELD_HIDING)
When enabled, the compiler will issue an error or a warning whenever a field declaration is hiding some field or local variable (either locally, inherited or defined in enclosing type). ERROR
WARNING
IGNORE
Reporting Special Parameter Hiding another Field (COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD)
When enabled, the compiler will signal cases where a constructor or setter method parameter declaration is hiding some field (either locally, inherited or defined in enclosing type). ENABLED
DISABLED
Reporting Possible Accidental Boolean Assignment( COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT)
When enabled, the compiler will issue an error or a warning if a boolean assignment is acting as the condition of a control statement (where it probably was meant to be a boolean comparison). ERROR
WARNING
IGNORE
Reporting Undocumented Empty Block (COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK)
When enabled, the compiler will issue an error or a warning when an empty block is detected and it is not documented with any comment. ERROR
WARNING
IGNORE
Reporting Finally Blocks Not Completing Normally (COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING)
When enabled, the compiler will issue an error or a warning when a finally block does not complete normally. ERROR
WARNING
IGNORE
Reporting Unused Declared Thrown Exception (COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION)
When enabled, the compiler will issue an error or a warning when a method or a constructor is declaring a thrown checked exception, but never actually raises it in its body. ERROR
WARNING
IGNORE
Reporting Unused Declared Thrown Exception in Overridind Method (COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING)
When disabled, the compiler will not include overriding methods in its diagnosis for unused declared thrown exceptions. ENABLED
DISABLED
Reporting Unqualified Access to Field (COMPILER_PB_UNQUALIFIED_FIELD_ACCESS)
When enabled, the compiler will issue an error or a warning when a field is access without any qualification. In order to improve code readability, it should be qualified, e.g. 'x' should rather be written 'this.x'. ERROR
WARNING
IGNORE
Reporting Invalid Javadoc Comment (COMPILER_PB_INVALID_JAVADOC)
This is the generic control for the severity of Javadoc problems. When enabled, the compiler will issue an error or a warning for a problem in Javadoc. ERROR
WARNING
IGNORE
Visibility Level For Invalid Javadoc Tags (COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY)
Set the minimum visibility level for Javadoc tag problems. Below this level problems will be ignored. PUBLIC
PROTECTED
DEFAULT
PRIVATE
Reporting Invalid Javadoc Tags (COMPILER_PB_INVALID_JAVADOC_TAGS)
When enabled, the compiler will signal unbound or unexpected reference tags in Javadoc. A 'throws' tag referencing an undeclared exception would be considered as unexpected.
Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc; also see the setting "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility".
ENABLED
DISABLED
Reporting Missing Javadoc Tags (COMPILER_PB_MISSING_JAVADOC_TAGS)
This is the generic control for the severity of Javadoc missing tag problems. When enabled, the compiler will issue an error or a warning when tags are missing in Javadoc comments.
Note that this diagnosis can be enabled based on the visibility of the construct associated with the Javadoc.
ERROR
WARNING
IGNORE
Visibility Level For Missing Javadoc Tags (COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY)
Set the minimum visibility level for Javadoc missing tag problems. Below this level problems will be ignored. PUBLIC
PROTECTED
DEFAULT
PRIVATE
Reporting Missing Javadoc Tags on Overriding Methods (COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING)
Specify whether the compiler will verify overriding methods in order to report Javadoc missing tag problems. ENABLED
DISABLED
Reporting Missing Javadoc Comments (COMPILER_PB_MISSING_JAVADOC_COMMENTS)
TThis is the generic control for the severity of missing Javadoc comment problems. When enabled, the compiler will issue an error or a warning when Javadoc comments are missing.
Note that this diagnosis can be enabled based on the visibility of the construct associated with the expected Javadoc.
ERROR
WARNING
IGNORE
Visibility Level For Missing Javadoc Comments (COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY)
Set the minimum visibility level for missing Javadoc problems. Below this level problems will be ignored. PUBLIC
PROTECTED
DEFAULT
PRIVATE
Reporting Missing Javadoc Comments on Overriding Methods (COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING)
Specify whether the compiler will verify overriding methods in order to report missing Javadoc comment problems. ENABLED
DISABLED
Setting Source Compatibility Mode (COMPILER_SOURCE)
Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM level should be set to "1.4" and the compliance mode should be "1.4". VERSION_1_3
VERSION_1_4
Setting Compliance Level (COMPILER_COMPLIANCE)
Select the compliance level for the compiler. In "1.3" mode, source and target settings should not go beyond "1.3" level. VERSION_1_3
VERSION_1_4
Maximum number of problems reported per compilation unit (COMPILER_PB_MAX_PER_UNIT)
Specify the maximum number of problems reported on each compilation unit (if the maximum is zero then all problems are reported). a positive integer.
Default value is 100
Define the Automatic Task Tags (COMPILER_TASK_TAGS)
When the tag is non empty, the compiler will issue a task marker whenever it encounters one of the corresponding tag inside any comment in Java source code.  Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed. {<tag>[,<tag>]*}.
Default value is "TODO,FIXME,
XXX"
Define the Automatic Task Priorities (COMPILER_TASK_PRIORITIES)
In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low) of the task markers issued by the compiler.  If the default is specified, the priority of each task marker is "NORMAL". Possible priorities are "HIGH", "NORMAL" or "LOW" {<priority>[,<priority>]*}.
Default value is "NORMAL,HIGH,
NORMAL"
Determine whether task tags are case-sensitive (COMPILER_TASK_CASE_SENSITIVE)
When enabled, task tags are considered in a case-sensitive way. ENABLED
DISABLED

Builder options

Description Values
Specifying Filters for Resource Copying Control (CORE_JAVA_BUILD_RESOURCE_COPY_FILTER)
Specify filters to control the resource copy process. (<name> is a file name pattern (only * wild-cards allowed) or the name of a folder which ends with '/') {<name>[,<name>]*}.
Default value is ""
Abort if Invalid Classpath (CORE_JAVA_BUILD_INVALID_CLASSPATH)
Instruct the builder to abort if the classpath is invalid ABORT
IGNORE
Cleaning Output Folder(s) (CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER)
Indicate whether the JavaBuilder is allowed to clean the output folders when performing full build operations. CLEAN
IGNORE
Reporting Duplicate Resources (CORE_JAVA_BUILD_DUPLICATE_RESOURCE)
Instruct the builder to abort if the classpath is invalid ERROR
WARNING

JavaCore options

Description Values
Computing Project Build Order (CORE_JAVA_BUILD_ORDER)
Indicate whether JavaCore should enforce the project build order to be based on the classpath prerequisite chain. When requesting to compute, this takes over the platform default order (based on project references). COMPUTE
IGNORE
Specify Default Source Encoding Format (CORE_ENCODING)
Get the encoding format for compiled sources. This setting is read-only, it is equivalent to ResourcesPlugin.getEncoding(). any of the supported encoding name.
Default value is platform default
Reporting Incomplete Classpath (CORE_INCOMPLETE_CLASSPATH)
Indicate the severity of the problem reported when an entry on the classpath doesn't exist, is not legitimate, or is not visible (e.g. a referenced project is closed). ERROR
WARNING
Reporting Classpath Cycle (CORE_CIRCULAR_CLASSPATH)
Indicate the severity of the problem reported when a project is involved in a cycle. ERROR
WARNING
Reporting Incompatible JDK Level for Required Binaries (CORE_INCOMPATIBLE_JDK_LEVEL)
Indicate the severity of the problem reported when a project prerequisites another project or library with an incompatible target JDK level (e.g. project targeting 1.1 vm, but compiled against 1.4 libraries). ERROR
WARNING
IGNORE
Enabling Usage of Classpath Exclusion Patterns (CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS)
When set to "disabled", no entry on a project classpath can be associated with an exclusion or inclusion pattern. ENABLED
DISABLED
Enabling Usage of Classpath Multiple Output Locations (CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS)
When set to "disabled", no entry on a project classpath can be associated with a specific output location, preventing thus usage of multiple output locations ENABLED
DISABLED

Formatter options

Description Values
Inserting New Line Before Opening Brace (FORMATTER_NEWLINE_OPENING_BRACE)
When Insert, a new line is inserted before an opening brace, otherwise nothing is inserted INSERT
DO_NOT_INSERT
Inserting New Line Inside Control Statement (FORMATTER_NEWLINE_CONTROL)
When Insert, a new line is inserted between } and following else, catch, finally INSERT
DO_NOT_INSERT
Clearing Blank Lines (FORMATTER_CLEAR_BLANK_LINES)
When Clear all, all blank lines are removed. When Preserve one, only one is kept and all others removed. CLEAR_ALL
PRESERVE_ONE
Inserting New Line Between Else/If (FORMATTER_NEWLINE_ELSE_IF)
When Insert, a blank line is inserted between an else and an if when they are contiguous. When choosing to not insert, else-if will be kept on the same line when possible. INSERT
DO_NOT_INSERT
Inserting New Line In Empty Block (FORMATTER_NEWLINE_EMPTY_BLOCK)
When insert, a line break is inserted between contiguous { and }, if } is not followed by a keyword. INSERT
DO_NOT_INSERT
Splitting Lines Exceeding Length (FORMATTER_LINE_SPLIT)
Enable splitting of long lines (exceeding the configurable length). Length of 0 will disable line splitting a positive integer.
Default value is 80
Compacting Assignment (FORMATTER_COMPACT_ASSIGNMENT)
Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space is inserted before the assignment operator COMPACT
NORMAL
Defining Indentation Character (FORMATTER_TAB_CHAR)
Either choose to indent with tab characters or spaces TAB
SPACE
Defining Space Indentation Length (FORMATTER_TAB_SIZE)
When using spaces, set the amount of space characters to use for each indentation mark. a positive integer.
Default value is 4
Inserting space in cast expression (FORMATTER_SPACE_CASTEXPRESSION)
When Insert, a space is added between the type and the expression in a cast expression. INSERT
DO_NOT_INSERT

CodeAssist options

Description Values
Activate Visibility Sensitive Completion (CODEASSIST_VISIBILITY_CHECK)
When active, completion doesn't show that you can not see (e.g. you can not see private methods of a super class). ENABLED
DISABLED
Automatic Qualification of Implicit Members (CODEASSIST_IMPLICIT_QUALIFICATION)
When active, completion automatically qualifies completion on implicit field references and message expressions. ENABLED
DISABLED
Define the Prefixes for Field Name (CODEASSIST_FIELD_PREFIXES)
When the prefixes is non empty, completion for field name will begin with one of the proposed prefixes. {<prefix>[,<prefix>]*}.
Default value is ""
Define the Prefixes for Static Field Name (CODEASSIST_STATIC_FIELD_PREFIXES)
When the prefixes is non empty, completion for static field name will begin with one of the proposed prefixes. {<prefix>[,<prefix>]*}.
Default value is ""
Define the Prefixes for Local Variable Name (CODEASSIST_LOCAL_PREFIXES)
When the prefixes is non empty, completion for local variable name will begin with one of the proposed prefixes. {<prefix>[,<prefix>]*}.
Default value is ""
Define the Prefixes for Argument Name (CODEASSIST_ARGUMENT_PREFIXES)
When the prefixes is non empty, completion for argument name will begin with one of the proposed prefixes. {<prefix>[,<prefix>]*}.
Default value is ""
Define the Suffixes for Field Name (CODEASSIST_FIELD_SUFFIXES)
When the suffixes is non empty, completion for field name will end with one of the proposed suffixes. {<suffix>[,<suffix>]*}.
Default value is ""
Define the Suffixes for Static Field Name (CODEASSIST_STATIC_FIELD_SUFFIXES)
When the suffixes is non empty, completion for static field name will end with one of the proposed suffixes. {<suffix>[,<suffix>]*}.
Default value is ""
Define the Suffixes for Local Variable Name (CODEASSIST_LOCAL_SUFFIXES)
When the suffixes is non empty, completion for local variable name will end with one of the proposed suffixes. {<suffix>[,<suffix>]*}.
Default value is ""
Define the Suffixes for Argument Name (CODEASSIST_ARGUMENT_SUFFIXES)
When the suffixes is non empty, completion for argument name will end with one of the proposed suffixes. {<suffix>[,<suffix>]*}.
Default value is ""

Legal notices