Java Editor |
|
CamelCase in Quick Outline | The Quick Outline (Ctrl+O) and Quick Hierarchy (Ctrl+T) in the Java Editor now also support camelCase matching on the element name, quite similar to the Open Type dialog and Content Assist. The * and ? wildcards still work, of course. |
Quick Assist to convert enhanced for loop |
Ever encountered an enhanced for loop and needed access to the Iterator or to the loop index?
Now, you can just use a Quick Assist (Ctrl+1) to convert the loop:
|
Improved bracket matching support in Java editor |
The Java editor now supports highlighting of enclosing brackets.
This can be configured on the Java > Editor preference page.
Also, the Navigate > Go To > Matching Bracket action (Ctrl+Shift+P) now works everywhere in a file. If a bracket is not selected before invoking the action, the action navigates to the nearest enclosing end bracket. On invoking the action a second time, it navigates to the corresponding start bracket. On the third invocation, the original selection is restored. So far, a matching bracket was found when the caret was placed immediately after a bracket. Now, a matching bracket is found both when the caret is placed either immediately before or immediately after a bracket. You can hover over a closing curly brace and see the source near the matching opening brace in a hover. This is helpful when you want to see the code near the start of a long code block. The hover also tells the number of lines in the code block. The hover is also useful to temporarily 'highlight' a short code block. |
Javadoc hover shows parameter annotations | Javadoc hovers now render the annotations on method parameters: |
'*.class without source' file type |
The new *.class without source file type allows to associate an internal or external editor
to class files that have no source attached. This e.g. allows to open the class file in a decompiler:
|
Default implementations for correction proposals |
JDT now provides the following default implementations for correction proposals that can be used to contribute quick fixes and quick assists.
|
Content assist in package-info.java | Content assist (Ctrl+Space) is now available inside package-info.java, which is used to declare package-level annotations and Javadocs. |
Java Compiler |
|
Selectively ignore errors/warnings from source folders |
You can now configure JDT to ignore optional errors/warnings from certain source folders.
Project properties > Java Build Path > Compiler > Source.
With this option set to Yes, JDT will suppress errors/warnings configured in the Preferences > Java > Compiler > Errors/Warnings page. This can be desirable for source folders that contain auto-generated classes or tests. |
Enhanced diagnostics for detection of incomplete switch statements |
The JDT's analysis regarding incomplete switch statements is now stronger and can be configured more in detail.
The compiler now separately checks two criteria for a switch statement to be complete:
By default the compiler warns for an enum switch where both criteria are violated: This warning is controlled by the option Preferences > Java > Compiler > Errors/Warnings > Incomplete 'switch' cases on enum. This option can be strengthened by selecting the new sub-option Signal even if 'default' case exists, in which case JDT will flag switch statements over an enum type which may have an enum value covered only through a default statement, but not directly through a case statement. When new enum constants are added, this option will help in detecting the switch statements that do not cover the new value. A second addition in the same section of the compiler preferences, Switch is missing 'default' case, controls whether the JDT will flag switch statements with a missing default case, because such a switch statement will be skipped entirely at runtime if an unexpected value occurs. Note that in cases like the above, the warning also helps to understand another
error against the last statement: |
New options to detect resource leaks | The compiler can now detect leakage of resources i.e. local variables of type
java.lang.AutoCloseable (compliance >= 1.7) and java.io.Closeable (compliance <= 1.6).
When the Resource leak option on the Java > Compiler > Errors/Warnings preference page is enabled,
the compiler will issue an error or a warning if the
When you enable the Potential resource leak option on the Java > Compiler > Errors/Warnings preference page,
the compiler will issue an error or a warning if the
This analysis is less aggressive if a resource is shared between methods, possibly via a field, where any party accessing the resource could possibly issue the desired call to close(). In some cases (e.g.: passed as an argument to another method) the warning will be softened to only report a potential leak, in other cases (stored in a field) the analysis will be entirely silent. Additionally the analysis recognizes certain cases as being practically unimportant. Some examples where the absence of a close() call does not trigger any error/warning are given below:
|
New Batch compiler warning options | Two new batch compiler options are now available to configure the
compile time warnings:
|
New build path option to warn when a source folder's output location overlaps another source folder | JDT now shows a build path error when a source folder's output location overlaps another source folder.
This error can be configured on the Java > Compiler > Building > Output location overlaps source location preference page.
|
Annotation-based null analysis |
JDT can now be configured to use annotations designated as null annotations to
perform enhanced inter-procedural null analysis. This feature can be enabled in
Preferences > Java > Compiler > Errors/Warnings > Null analysis:
You can use either the default annotations bundled with JDT or use your own annotations
as null annotations. In addition to enabling the null analysis, the annotations need to be on the
Java build path of your project. The default annotations can be found in the org.eclipse.jdt.annotation JAR
in the When annotation-based null analysis is enabled, JDT issues new diagnostics based on the nullness of a variable or a method return type as specified by a null annotation. Similar diagnostics are also elicited when the value assigned/returned may potentially be null or has unknown nullness. Overriding methods are also checked for correctness: You can also use the As a result of annotating method signatures, the existing intra-procedural null analysis has even more information because of user-specified annotations and thus provides better results. In the example below, the compiler would not have been able to evaluate the null status of parameter 'obj' without the null annotation (option Redundant null check must be enabled to see the warning). The new diagnostics are classified in three categories:
Note: This is the first version of this feature. We are working on making this easier to consume in Java project setups. The implemented features are complete and tested, but e.g. support for annotating fields or APIs from third-party libraries is currently missing. An initial set of quick fixes is included which will be further improved in the future. |
Batch compiler options for using null annotations |
You can now configure the batch compiler to use annotations for null analysis by passing the token nullAnnot(nullable|nonnull|nonnullbydefault) to the -warn option,
where nullable, nonnull and nonnullbydefault are the fully qualified names of the annotation types to be used for null analysis. You can use nullAnnot alone
to use JDT's default annotations.
In addition, you can use the -nonNullByDefault token to globally use nonnull as the default when annotation-based null analysis is enabled. This implies that all types in method signatures without a null annotation are considered as specified non-null. |
Detection of missing default nullness annotation |
In order to make non-null the default for un-annotated types in method signatures you may
use the '@NonNullByDefault' annotation on all packages.
To ensure full coverage of all packages you can configure JDT to detect a missing default nullness annotation.
When Preferences > Java > Compiler > Errors/Warnings > Null analysis > Missing '@NonNullByDefault' annotation on package
is enabled, JDT will issue an error/warning in the following cases:
|
Null analysis treats org.eclipse.core.runtime.Assert like Java assert | Since org.eclipse.core.runtime.Assert is often used just like the Java assert keyword, JDT's null analysis considers the boolean expression passed into the former as always true after the Assert reference, since if the condition did turn out to be false, the control flow will never go further than the org.eclipse.core.runtime.Assert reference. |
Faster search with pre-built indexes |
Note: This feature is mainly intended for plug-ins that implement their own classpath container, not for the end user.
You can now tell JDT search to use pre-built indexes instead of having the compiler generate the indexes the first time a JAR is added to the classpath. This prevents indexing from occurring on the user's machine and lets the user obtain first search results faster. You can specify the index file as a classpath attribute See Help > JDT Plug-in Developer Guide > Programmer's Guide > JDT Core > Indexes for the Java search for more details. |
Java Views and Dialogs |
|
Encoding for source attachments | You can now specify the encoding for source attachments for libraries e.g. in Build Path > Libraries > expand the library > Source attachment > Edit... |
Highlighting on Errors/Warnings preference pages | On Errors/Warnings preference pages, it is sometimes hard to see which item is selected, especially when you opened the dialog via the "Configure Problem Severity" button. Now, an arrow highlights the selected item, and another arrow highlights the item under the mouse. The highlighting also works on the PDE and API Tools preference pages. |
Properties File Editor |
|
Quick assists to reorganize property keys |
If you use Eclipse-style externalized strings, the following new quick assists make it easier to
reorganize keys inside the Properties File Editor:
|
Debug |
|
Export detail formatters | Detail formatters (which are e.g. used to render objects in the Variables view) can now be exported as separate preferences. Previously, the only way to share detail formatters was to export all of your workspace settings. |
Show Monitors on by default |
The default setting for displaying monitor information in the Debug view is now set to on.
This change only affects new workspaces and does not change existing settings.
Showing monitor information can be turned on or off using the Java > Show Monitors view action within the Debug view. |
Toggle breakpoint modifier keys |
There is now support for modifier keys while toggling breakpoints in the Java editor:
|
JUnit |
|
JUnit 4.10 | The JUnit 4 version shipped with Eclipse has been updated to 4.10. |