Manipulating JDT Core options

JDT Core options are accessible from a few APIs. All of these APIs are located in JavaCore. Only four methods are necessary to manipulate the options:

The options are manipulated 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.

If you want to configure JDT Core with only your options, the following code fragment would work:

   // 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);
If you want to keep the current options and modify only one of them:
   // 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);

JDT Core options descriptions

The list of all the JDT Core options are in the following tables. All of the tables have the same organisation with the option id surrounded with parenthesis and the default value printed in bold italics.

Options category

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 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 Import (COMPILER_PB_UNUSED_IMPORT)
When enabled, the compiler will issue an error or a warning for unused import reference 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-$) 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
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

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

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

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

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

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