# Java Compiler

This preference page lets you configure the various settings related to compiling, building and checking Java source code.

The Java compiler preferences are separated in the following sections:

- General
- Building
- Errors/Warnings

## General

### JDK Compliance

Option | Description | Default
--- | --- | ---
Compiler compliance level | Specifies the compiler compliance level. | 1.4
Use default compliance settings | If enabled, the default compliance settings for the compiler compliance level are applied. | On
Generated class files compatibility | Specifies the generated class file compatibility. | 1.2
Source compatibility | Specifies the compatibility of the accepted source code. | 1.3
Disallow identifiers called 'assert' | When enabled, the compiler will issue an error or a warning whenever 'assert' is used as an identifier (reserved keyword in J2SE 1.4). | Warning
Disallow identifiers called 'enum' | When enabled, the compiler will issue an error or a warning whenever 'enum' is used as an identifier (reserved keyword in J2SE 5.0). | Warning

### Classfile generation

Add variable attributes to generated class files | If enabled, variable attributes are added to the class file. This will enable local variable names to be displayed in the debugger (in places where variables are definitely assigned) The resulting .class file is then bigger. | On
Add line number attributes to generated class files | If enabled, line number information is added to the class file. This will enable source code highlighting in the debugger. | On
Add source file name to generated class file | If enabled, the source file name is added to the class file. This will enable the debugger to present the corresponding source code. | On
Preserve unused local variables | If enabled, unused local variables (i.e. never read) are not stripped from the class file. If stripped this potentially alters debugging. | On
Inline finally blocks | If enabled, finally blocks are inlined in the generated class files. This positively affects performance, but may result in larger class files. | Off

## Building

### General

Option | Description | Default
--- | --- | ---
Maximum number of reported problems per compilation unit | Specifies how many problems should be reported for a compilation unit. | 100
Enable using exclusion patterns in source folders | When disabled, no entry on a project classpath can be associated with an exclusion pattern. | On
Enable using multiple output locations for source folders | When disabled, no entry on a project classpath can be associated with a specific output location, preventing thus usage of multiple output locations. | On

### Build path problems

Abort building on build path errors | Allow to toggle the builder to abort if the classpath is invalid. | On
Incomplete build path | Indicate the severity of the problem reported when an entry on the classpath does not exist, is not legitimate or is not visible (e.g. a reference project is closed). | Error
Circular dependencies | Indicate the severity of the problem reported when a project is involved in a cycle. | Error
Incompatible required binaries | Indicated the severity of the problem reported when a project requires incompatible binaries. | Ignore

### Output folder

Duplicated resources | Indicate the severity of the problem reported when more than one occurrence of a resource is to be copied into the output location. | Warning
Scrub output folders when cleaning projects | Indicate whether the Java Builder is allowed to clean the output folders when performing full build operations. | On
Filtered resources | A comma separated list of file patterns which are not copied to the output folder. | ''

## Errors/Warnings

### Code style

Option | Description | Default
--- | --- | ---
Non-static access to a static member | When enabled, the compiler will issue an error or a warning whenever a static field or method is accessed with an expression receiver. A reference to a static member should be qualified with a type name. | Warning
Indirect access to a static member | When enabled, the compiler will issue an error or a warning whenever a static field or method is indirectly accessed. A static field of an interface should be qualified with the declaring type name. | Warning
Unqualified access to instance field | When enabled, the compiler will issue an error or a warning whenever it encounters a field access which is not qualified (eg. misses a 'this'). | Ignore
Undocumented empty block | When enabled, the compiler will issue an error or a warning whenever it encounters an empty block statement with no explaining comment. | Ignore
Access to a non-accessible member of an enclosing type | 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 accesses can have performance implications. | Ignore
Methods with a constructor name | Naming a method with a constructor name is generally considered poor style programming. When enabling this option, the compiler will signal such scenario either as an error or a warning. | Warning
Usage of non-externalized strings | When enabled, the compiler will issue an error or a warning for non externalized String literal (i.e. non tagged with //$NON-NLS-<n>$). | Ignore

### Potential programming problems

Serializable class without serialVersionUID | When enabled, the compiler will issue an error or a warning whenever a type implementing 'java.io.Serializable' does not contain a serialVersionUID field. | Warning
Assignment has no effect (eg. 'x = x') | When enabled, the compiler will issue an error or a warning whenever an assignment has no effect (eg. 'x = x'). | Warning
Possible accidential boolean assigment (eg. 'if (a = b)') | When enabled, the compiler will issue an error or a warning whenever if encounters a possible accidential boolean assignment (eg. 'if (a = b)'). | Warning
'finally' does not complete normally | When enabled, the compiler will issue an error or a warning whenever a 'finally' statement does not complete normally (eg. contains a return statement). | Warning
Empty statement | When enabled, the compiler will issue an error or a warning whenever it encounters an empty statement (eg. a superfluos semicolon). | Ignore
Using a 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, `"hello" + new char[]{'w','o','r','l','d'}` | Warning
Hidden catch blocks | Locally to a try statement, some catch blocks may hide others , eg. `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. | Warning

### Name shadowing and conflicts

Field declaration hides another field or variable | When enabling this option, the compiler will issue an error or a warning if a field declaration hides another inherited field. | Ignore
Local variable declaration hides another field or variable | When enabling this option, the compiler will issue an error or a warning if a local variable declaration hides another field or variable. | Ignore
Include constructor or setter method parameters | When enabling this option, the compiler additionally will issue an error or a warning if a constructor or setter method parameter hides another field or variable. | Off
Type parameter hides another type | When enabling this option, the compiler will issue an error or a warning if eg. a type parameter of an inner class hides an outer type. | Warning
Methods overridden but not package visible | 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 scenario either as an error or a warning. | Warning
Conflict of interface method with protected 'Object' method | When enabled, the compiler will issue an error or a warning whenever an interface defines a method incompatible with a non-inherited Object method. Until this conflict is resolved, such an interface cannot be implemented, eg. `interface I {` `int clone();` `}` | Warning

### Name shadowing and conflicts

Deprecated API | When enabled, the compiler will signal use of deprecated API either as an error or a warning. | Warning
Signal use of deprecated API inside deprecated code | When enabled, the compiler will signal use of deprecated API inside deprecated code. The severity of the problem is controlled with option "Deprecated API". | Off
Signal overriding or implementing deprecated method | When enabled, the compiler will signal overriding or implementing a deprecated method The severity of the problem is controlled with option "Deprecated API". | Off
Forbidden reference (access rules) | When enabled, the compiler will signal a forbidden reference specified in the access rules. | Error
Discouraged reference (access rules) | When enabled, the compiler will signal a discouraged reference specified in the access rules. | Warning

### Unnecessary code

Local variable is never read | When enabled, the compiler will issue an error or a warning whenever a local variable is declared but never used within the its scope. | Warning
Parameter is never read | When enabled, the compiler will issue an error or a warning whenever a parameter is declared but never used within the its scope. | Ignore
Check overriding and implementing methods | When enabled, the compiler additionally will issue an error or a warning whenever a parameter is declared but never used within the its scope in overriding or implementing methods. | Off
Unused imports | When enabled, the compiler will issue an error or a warning for unused import reference. | Warning
Unused local or private members | When enabled, the compiler will issue an error or a warning whenever a local or private member is declared but never used within the same unit. | Warning
Unnecessary else statement | When enabled, the compiler will issue an error or a warning whenever it encounters an unnecessary else statement (eg. if (condition) return; else doSomething();). | Ignore
Unnecessary cast or 'instanceof' operation | When enabled, the compiler will issue an error or a warning whenever it encounters an unnecessary cast or 'instanceof' operation (eg. if (object instanceof Object) return;). | Ignore
Unnecessary declaration of thrown checked exception | When enabled, the compiler will issue an error or a warning whenever it encounters an unnecessary declaration of a thrown exception. | Ignore
Check overriding and implementing methods | When enabled, the compiler additionally will issue an error or a warning whenever it encounters an unnecessary declaration of a thrown exception in an overriding or implementing method. | Off

### J2SE 5.0 options

Unchecked generic type operation | When enabled, the compiler will issue an error or a warning whenever it encounters an unchecked generic type operation. | Warning
Generic type parameter declared with a final type bound | When enabled, the compiler will issue an error or a warning whenever it encounters a type bound involving a final type. | Warning
Inexact type match for vararg arguments | When enabled, the compiler will issue an error or a warning whenever it encounters an inexact type match for vararg arguments. | Warning
Boxing and unboxing conversions | When enabled, the compiler will issue an error or a warning whenever it encounters a boxing or unboxing conversion. Autoboxing may affects performance negatively. | Ignore
Missing '@Override' annotation | When enabled, the compiler will issue an error or a warning whenever it encounters a method overriding another implemented method, and the '@Override' annotation is missing. | Ignore
Missing '@Deprecated' annotation | When enabled, the compiler will issue an error or a warning whenever it encounters a deprecated type without additional '@Deprecated' annotation. | Ignore
Annotation is used as super interface | When enabled, the compiler will issue an error or a warning whenever it encounters a type implementing an annotation. Although possible, this is considered bad practice. | Warning
Not all enum constants covered on 'switch' | When enabled, the compiler will issue an error or a warning whenever it encounters a switch statement which does not contain case statements for every enum constant of the referenced enum. | Ignore
Unhandled warning tokens in '@SuppressWarnings' | When enabled, the compiler will issue an error or a warning whenever it encounters an unhandled warning token in a '@SuppressWarnings' annotation. | Warning
Enable '@SuppressWarnings' annotations | When enabled, the compiler will process '@SuppressWarnings' annotations. | On

Java builder

Building a Java program
Working with build paths
Working with JREs

Classpath Variables preferences
Java Build Path properties