Java development tools

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

Java 7 support: Indigo does not contain Java 7 support because Java 7 was not publicly released when Indigo shipped. Those who want to use Java 7 in Eclipse can download a 3.7 maintenance build (>= M20110729-1400), a 3.8 build (>= I20110729-1200), a 4.1 maintenance build (>= M20110803-1400) or a recent 4.2 build (>= I20110729-0200). See What's new for Java 7 for the new Java 7 related features.


Java Editor

Open Java element from clipboard The new Navigate > Open from Clipboard command tries to open the matching Java element in the editor if the clipboard contains a single line. Otherwise it opens the contents in the Java Stack Trace Console.

Examples:
  • java.lang.String
  • String
  • String#getBytes
  • String.getBytes
  • java.lang.String.getBytes(String)
  • String.java:123
  • at java.lang.String.matches(String.java:1550)
  • java.lang.String.valueOf(char) line: 1456
  • currentTimeMillis()

Note: If the action is not enabled in a certain perspective, then you can enable the Java Debug action group in Window > Customize Perspective > Command Groups Availability.

"Introduce new local with cast type" quick assist The Introduce new local with cast type quick assist (Ctrl+1) is now not only available on the instanceof keyword, but also in the body of the conditional statement (before the first body statement).

Introduce new local with cast type

"Join variable declaration" quick assist for variables initialized to null The Join variable declaration quick assist is now also available for variables initialized to null.

Join variable declaration

"Exchange Operands" quick assist for comparison operators The Exchange left and right operands for infix expression quick assist is now also available for the !=, <, <=, >, and >= operators.

Exchange Operands

New 'Put expression in parentheses' quick assist The Java editor now offers a new quick assist Put expression in parentheses.

Put expression in parentheses

Also the Add paranoiac parentheses quick assist has been renamed to Put expressions in parentheses.

Put expressions in parentheses

'Add missing case statements' quick assist The Add missing case statements quick assist is now available in the body of the switch statement:

Add missing case statements

Semantic coloring for abstract classes Abstract classes can now be highlighted separately in the source code:

Semantic coloring for abstract classes

The rendering can be configured on the Java > Editor > Syntax Coloring preference page.

Quick Outline shows inherited members for nested type The Quick Outline shows inherited members of top-level types when Ctrl+O is pressed twice. Now, it also shows inherited members of the type that contains the current editor selection:

Quick Outline showing inherited members for a nested type

The focus types that can show inherited members are marked with a triangle ( Focus adornment ).

Ctrl+drag to add to Call Hierarchy Ctrl+drag now adds the selected methods to the existing elements in the Call Hierarchy view. Plain drag and drop continues to replace the view input with the selected methods.
Navigate to {@inheritDoc} target To quickly navigate to the target of an {@inheritDoc} tag in a Javadoc comment, you can now Ctrl+click the tag or use Navigate > Open Declaration to jump to the method that defines the inherited doc.

@inheritDoc tag on X2.foo() that overrides X1.foo()

In this example, the target of the @inheritDoc inline tag on X2.foo() is X1.foo().

Format Java elements via Outline view You can now format one or more selected elements in the Java Outline view by invoking Source > Format Element from the main menu.
Disable smart indentation on 'Enter' A new preference has been added to the Java > Editor > Typing preference page that allows to disable smart indentation after the Enter key has been pressed:

Enter Key Indent Preference

Java Formatter

New line after annotations The Insert new line after annotations on members option on the 'New Lines' tab of the formatter preferences has been split up to support packages, types, fields and methods:

Java formatter preference page. Check the preference on the 'New Lines' tab of the formatter profile.

For example, with this preference activated as shown above, the formatted code looks like this:

Java formatter example. The simple snippet with the annotations formatted.

Formatter profiles can be configured on the Java > Code Style > Formatter preference page.

Preserve whitespace before line comment A code formatter option has been added to preserve white space between code and line comments:

Code snippet with tabs in front of a line comment

This preference can be enabled on the Java > Code Style > Formatter preference page on the Comments tab:

Formatter preference page

Java Compiler

New option to include 'assert' in null analysis JDT now gives the flexibility to enable or disable null-related errors/warnings on variables that got marked as potentially or definitely null inside an assert statement. If you have runtime asserts enabled, you can also enable the new warning to see the null-related problems being reported because of null-related checks inside the assert statement. If the option is disabled, null checks in asserts are not considered.

Example of asserts included in null analysis

The new option Include 'assert' in null analysis is disabled by default and can be enabled on the Java > Compiler > Errors/Warnings preference page.

Missing Javadoc tags for method type parameters no longer reported by default JDT now provides an option to enable or disable the missing Javadoc tag error or warning for a method type parameter without a corresponding @param tag.

Example of Javadoc without @param tags for method type parameters

The new Ignore method type parameters option is enabled by default and can be disabled on the Java > Compiler > Errors/Warnings preference page.

Improved detection of unused local variables, parameters and fields JDT now reports local variables, parameters, and fields of a primitive type as unused in the following scenarios:
  • compound assignment
  • prefix/postfix increment/decrement expression

Example of unused local variable

In case the above expressions involve an unboxing operation, the variable is not reported as unused.

We also changed the wording from "X has never been read" to "The value of X is not used."

Filter preferences on Java > Compiler > Errors/Warnings page You can now filter preferences on the Java > Compiler > Errors/Warnings page by preference label text or by preference value. A word in the filter string preceded by '~' is used to filter on preference values. Examples:
  • param
  • ~off
  • ~ignore
  • param ~enabled
  • ~ignore param

Filter preferences

Unavoidable generic type problems A new compiler option has been added that suppresses unavoidable generic type problems.

compiler option on the Errors/Warnings page

Those problems only show up because a type refers to an old API that uses raw types.

example code

When the old API is eventually generified, then these problems either go away, or you will see a compile error because the type arguments you used are not correct.

This option is disabled by default but can be enabled on the Java > Compiler > Errors/Warnings preference page.

Compiler detects methods that can be static Two new compiler options have been added that mark methods which can be made static because they only refer to static members.

'Method can be static' compiler options on the Errors/Warnings page

The first option marks private and final methods than can always be made static.
The second option also marks other methods. Note that methods can be overridden in a subclass, so if you make a "potentially static" method static, this may break existing clients.

These options are disabled by default.

On-disk JRE change detection In the past, if a system update or another event changed a JRE used in Eclipse, those changes would not be reflected in Eclipse: In some cases, this caused the JRE to stop functioning. Now, these changes are accounted for, and any JRE that changed on-disk (external to Eclipse) will be updated accordingly when Eclipse restarts.
New "javadoc" token for @SuppressWarnings annotation The @SuppressWarnings annotation can now also be used to suppress compiler warnings/errors related to Javadoc issues:

Suppress javadoc warnings using @SuppressWarnings("javadoc") annotation

Java Views and Dialogs

Open Type Hierarchy on multiple type containers The Open Type Hierarchy action now also works on multiple type containers: You can select multiple packages, source folders, or projects, and then open a hierarchy that contains all types in the selected containers.
Pin the Call Hierarchy view The Call Hierarchy view now allows to pin the current view, which allows you to open multiple Call Hierarchy views at the same time:

Pin the Call Hierarchy View action

Configure 'Search In...' in Call Hierarchy A new Search In... action has been added to the Call Hierarchy view menu. The action shows the Search In dialog with the same options that are already available in the Search dialog.

Search In options

History for breakpoint conditions There is now a history for recently used breakpoint conditions:

Breakpoint condition history

Prompt before deleting conditional breakpoints In the Java editor, if you delete a breakpoint that has a condition set on it, you will now be prompted before the breakpoint gets deleted:

Prompt when deleting a breakpoint

You can specify that you would not like to be notified again when trying to remove a conditional breakpoint. This can later be changed again via Prompt for confirmation when deleting a conditional breakpoint from editor on the Java > Debug preference page.

Step filtering for bean-style getters and setters When single stepping, you can now automatically step over simple getters and setters during Step Into:

Options for step filtering on simple getters and setters

Consider single stepping into statements like:

computeEffect(meters.getCurrent(), meters.getVoltage());

Normally, this means first stepping into getCurrent, then into getVoltage, and finally into computeEffect. You can now skip the first two steps (provided they are simple bean-style getters), and jump directly into the computeEffect method, by selecting the Filter simple getters check box on the Java > Debug > Step Filtering preference page.

Similarly, selecting Filter simple setters avoids stopping inside simple bean-style setters when using Step Into.

Properties File Editor

New "Escape backslashes" and "Unescape backslashes" quick assists in properties file editor The properties file editor now offers two new quick assists (Ctrl+1) to escape or unescape backslashes.

Escape backslashes Uescape backslashes

The Escape backslashes quick assist is also offered automatically on paste if the pasted text contains backslashes that should be escaped.
Auto-escaped characters and editor hovers The properties file editor now auto-escapes typed and pasted non-ISO-8859-1 characters and shows a hover containing the real text if the underlying text contains special characters like \uHHHH, \t, or \n.

Properties file editor hover

JUnit

New JUnit Test Suite wizard supports JUnit 4 The New > JUnit Test Suite wizard can now also create JUnit 4 test suites:

New JUnit Test Suite wizard

Result:
@RunWith(Suite.class)
@SuiteClasses({ ListTest.class, SimpleTest.class })
public class AllTests {
}
Show latest JUnit test in all windows By default, a new JUnit test run only shows up in the window where the test was started. If you prefer to see the latest test in all open JUnit views, select Preferences > Java > JUnit > Show newly launched test in all JUnit views:

JUnit preference page

Paste URL into JUnit view Apart from drag-and-drop or Test Run History > Import from URL..., you can now also paste a URL into the JUnit view to load test results from the web.

Supported test run formats are XML files exported from the JUnit view or generated by the Ant JUnit task.

Previous     Next


Sun, Solaris, Java and all Java-based trademarks are trademarks of Oracle Corporation. in the United States, other countries, or both.