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);

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
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 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 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 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
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 ""
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". {<priority>[,<priority>]*}.
Default value is ""

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

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
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 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 ""

 Copyright IBM Corporation and others 2000, 2003. All Rights Reserved.