What's New in Oxygen (JDT)

Here are descriptions of some of the more interesting or significant changes made to the Java development tools (JDT) for the Oxygen (4.7) release of Eclipse. They are grouped into:

See also the Eclipse Platform What's New document for changes in the Platform.

We also recommend to read the Tips and Tricks.


Java Editor

Open Implementation of selected Type The Open Implementation hyperlink and the Navigate > Open Implementation action now open the implementation of the selected interface or class also. In the past, Open Implementation was only available for methods.

The hyperlink popup shows up when you hold Ctrl (on the Mac: Command), unless you've changed the modifier on the Hyperlinking preference page.
Automatically insert Braces at correct position The Java > Editor > Typing > Automatically insert at correct position > Braces preference option is now enabled by default. This will automatically insert the braces where they are required.

Escape text when pasting into a string literal The Java > Editor > Typing > Escape text when pasting into a string literal preference option is now enabled by default. This will escape the special characters in pasted strings when they are pasted into an existing string literal.

To paste without escaping, you can either paste outside of a string literal, or you can disable Edit menu > Smart Insert Mode.
Quick Fix to move type annotations The rules for the placement of Java 8 "type annotations" introduced via JSR 308 are sometimes surprising. In case of errors, a new Quick Fix Move type annotation is offered, that moves the type annotation to a location that corresponds to what was probably intended.

Defaults for annotation type elements in Javadoc The default value of an annotation type element is now shown in the Javadoc view and hover.

Set colors for Javadoc You can use the new color preferences to set the foreground text color and the background color in the Javadoc view and hovers:

Consistent Javadoc colors usage under Linux The Javadoc color usage on Linux was inconsistent since GTK 3.04. This has been resolved and support for Javadoc on the Eclipse Dark Theme has been added.

Before:

After:

Dark theme support:

Java Views and Dialogs

Skip button in Organize Imports dialog While using the Organize Imports dialog to import multiple unresolved types, you can now skip a type without cancelling the whole operation by using the new Skip button. No import statement is added for the skipped type.

Hide inherited members from java.lang.Object You can hide all inherited members from java.lang.Object in the Quick Outline (Ctrl+O) by using the new filter from the drop-down menu (Ctrl+F10):

Hide deprecated fields and methods You can now hide the deprecated fields and methods in Outline view, Members view, Package Explorer view, Project Explorer view, and Quick Outline by using the new filter from their drop-down menu (Ctrl+F10):

Group by Project in Search view The default grouping of Java search results in the Search view has been changed to Group by Project. Earlier the results were grouped by package.

You can use the buttons in the view tool bar to Group by Project, Package, File, or Type.
Type name with extension in New Java Type creation wizards New Java Type creation wizards now accept the .java extension with the type name instead of showing the error message: "Type name must not be qualified". For example, to create a new class com.test.C1<T>.java, you can directly paste this qualified type name with extension in the Name field of the New Java Class wizard.

HiDPI JDT icons Composite icons such as Java element icons with modifier overlays are now rendered in high resolution in environments that support HiDPI images.

Java Compiler

New Java index Eclipse 4.7 contains an experimental new Java index which is disabled by default.
As a thumb rule, you can try the new indexing to get better performance when there are a large number of Jar dependencies. The new index has been adopted completely in the Type Hierarchy view and partially in some features that use the binary file caching (jars and .class files) such as Package Explorer expansion for jars. It hasn't been adopted by the search features.

You can enable the new index from Preferences > Java:

To improve performance, the new index captures a lot of semantic information in an index file separate from the classic index file, consuming additional memory and disk space. The new Rebuild Index button can be used to delete the existing index files - both classic as well as new - then rebuild these index files from scratch. If Enable new Java index option is not checked, only the classic index file will be rebuilt though both will be deleted, thus saving disk space. Also, if index corruption is suspected, Rebuild Index can be used to start from a clean slate again.
Pass compiler options to annotation processors You can now pass compiler options to annotation processors using %variable% syntax in Project > Properties > Java Compiler > Annotation Processing.

This allows processors to compile Java sources using the Java project's settings without manually maintaining this information in the processor options.
Warnings for unlikely argument types Many developers have learned the hard way, that certain uses of Java collections that pass the compiler's type check, may still contain "type errors", resulting in unexpected runtime behaviour. A new analysis has been added to the Eclipse compiler for Java that will detect the most common bugs in this area.

The common reason behind this problem is the fact that not all methods of those collection types make use of generics in the way one might expect. As a result it is possible to create a Set<Short>, whose add(Short) method will only accept arguments of type Short, yet method remove(Object) will happily accept literally any argument, because the method's parameter has type Object.

Here is a code snippet that seems to add and remove the same element from the set, but at a closer look the remove call has no effect. What is difficult to see for the naked eye is now flagged by a new warning:

Warning on last line: Unlikely argument type int for remove(Object) on a Collection<Short>

In a simple world, this would be all there is to say, but over time people have developed various code patterns that rely on these overly general signatures. Consider the following use of subtyping:

Depending on your coding style this may or may not be accepted as a legitimate short hand for:
if (n instanceof Short) set.remove((Short) n);
To reduce the churn caused by the new analysis, we developed some heuristics that filter out cases where types are "sufficiently similar", so the above goes unwarned.

As with any heuristic, there is no clear line. This implies that the compiler may show "unwanted" warnings, or filter out invocations that are in fact bugs. For the former case, @SuppressWarnings("unlikely-arg-type") will document the exception both for the user and for the compiler. For the latter case, we provide an option to tighten the rules, namely to apply strict type compatibility checks instead of said heuristics. For this extra scrutiny you may enable the sub-option Perform strict analysis against the expected type in Preferences > Java > Compiler > Errors/Warnings > Potential programming problems.

Preference options

Similarly, a check with default severity "Info" is offered for unlikely invocations of java.lang.Object.equals(Object) and java.util.Objects.equals(Object,Object).

Info on last line: Unlikely argument type for equals(): Name seems to be unrelated to String

Java Formatter

New way to count comment width A new option has been added in the code formatter profile editor that makes the formatter count a comment's width from its starting position instead of the beginning of the line.

You can change this option in the Java > Code Style > Formatter preferences in the Comments tab, under Line width.

This option allows more space for comments in heavily indented blocks of code and for line comments added to the right of some code. And at the same time, it keeps comments that start at the beginning of the line from getting too wide and uncomfortable to read.

Debug

Method result after step operations During debugging, the last method result (per return or throw) that was observed during Step Into, Step Over or Step Return, is shown as first line in the Variables view.

This can be disabled with the new option Preferences > Java > Debug > Show method result after a step operation (if supported by the VM; may be slow)

Triggers for breakpoints You can now define a set of triggers for the breakpoints in a workspace.

Any breakpoint can be set as a trigger point by using Breakpoint Properties... dialog or the Breakpoints view's detail pane.

Triggers will be rendered with an overlay of "T" and the breakpoints suppressed by the triggers will be rendered with an overlay of "T" with a cut.

All the other breakpoints that are initially suppressed by triggers will be hit only after any of the trigger points has been hit. All the triggers are disabled after a trigger point is hit and will be re-enabled after the run.

Conditional watchpoint Like for line breakpoints, conditions can now also be added to Watchpoints, where the old value of the field can be used as part of the condition.

Toggle Tracepoint A new action Run > Toggle Tracepoint has been added.

The action creates a conditional breakpoint using the "systrace" template, which prints the class and method name.

This makes use of another new feature of conditional breakpoints: As long as the condition doesn't explicitly return a boolean true, the condition is now considered to implicitly return false, and the breakpoint will not suspend execution.
Show Logical Structure enabled by default In the Variables view, Show Logical Structure is now enabled by default. E.g. collection objects now directly show their contained elements instead of their internal structure.

The Show Logical Structure context menu lets you choose or edit the representation.

Remote Java Application "Socket Listen" type supports multiple incoming connections The Remote Java Application debug configuration's Standard (Socket Listen) connection type now supports incoming connections from multiple VMs. This is useful for debugging distributed systems. The connection limit may be set to a fixed number, or 0 for unlimited connections.

New option to disable Hot Code Replace You can now disable Hot Code Replace (HCR) if it causes any trouble or if you want to avoid code changes in a debug target. HCR is enabled by default but can be disabled in Preferences > Java > Debug.

JUnit

Show JUnit failure trace in Console view A new button has been added to the JUnit Failure Trace header to show the stack trace of a failed JUnit test in the Console view. The Console view makes it convenient to view a long and wide stack trace, copy parts of the stack trace and navigate to the classes on the stack trace using hyperlinks.