Java development tools

Java Editor Breadcrumb

The Java editor now offers a breadcrumb which shows the path to the element at the cursor position. The breadcrumb can be enabled via the Toggle Breadcrumb tool bar button or by pressing Alt+Shift+B:

Picture showing the breadcrumb in the Java editor

Each element in the breadcrumb can be selected and actions can be invoked through a context menu or keyboard short cuts.

Context menu on breadcrumb item

Furthermore the breadcrumb lets you navigate to other elements via drop-downs.

Breadcrumb drop down

Rich Javadoc Hover

The Javadoc hover can now be used to navigate Javadoc.

  • Follow links in Javadoc
  • Go forward and backward in the navigation history
  • Show the current content in the Javadoc view
  • Open the declaration of the current element
  • Open the current content in an external browser
  • Resize the hover
  • Move the hover (start dragging in the toolbar area)

The enriched Javadoc hover

The hover also shows the icon corresponding to the current Java element

To enrich a hover either press F2 or move the mouse into the hover. You can configure how to enrich the hover on the General > Editors > Text Editors preference page.

Rich Java problem hover

The problem hover now offers all available quick fixes for a problem and shows a tool bar on F2 or when you move the mouse into it.

Enriched Problem Hover

Quick fixes can be executed by clicking on the links. The actions in the tool bar let you configure the annotation preferences and the problem severity.

Content assist improvements

Content Assist (Ctrl+Space) has been improved in several areas.

  • Content assist can now use the type of the enclosing instanceof condition to offer more field and method access proposals:

    Instanceof Completion Proposals

    The required cast will be inserted when such a proposal is selected.

  • Content assist for static members also work if the type has not been imported yet:

    Static Members Completion

    The required import will be added when such a proposal is selected.

  • Content assist can now propose methods with unknown types:

    Second example of missing types

  • Content assist on method invocations shows the guessed arguments:

    Content assist with proposed guessed arguments

    This can be configured on the Java > Editor > Content Assist preference page.

Quick assists

New quick assists (Ctrl+1) have been added in this release:

  • Create getter and setters: Available on fields.
    Screenshot of the 'create getter and setter' quick assist

  • Extract to method: Available on expressions and statements.
    Screenshot of the 'extract method' quick assist

  • Extract to local variable without replacing all occurrences: Available on expressions.
  • Use StringBuilder for string concatenation: Available on string concatenations.
    Picture showing the 'Convert to StringBuffer' quick assist
    StringBuilder is used in Java projects with a 1.5 or higher compliance, StringBuffer is used in projects with a lower compliance.
  • Use MessageFormat for string concatenation: Similar to convert to StringBuilder, MessageFormat is used to replace string concatenations.
    Picture showing the 'Convert to MessageFormat' quick assist

SWT Templates

A set of templates have been added to provide code building blocks for SWT widgets.

To add, for example, an SWT button, type Button and press Ctrl+Space, select the Button SWT template, and press Enter.

Create a button with the Button template

To see all available templates go to the Java > Editor > Templates preference page or open the Templates view through Window > Show View > Other....

New Template Variables

New template variables have been added and existing variables have been improved. Consult the Template Variables help page for a detailed overview.

Specify location for templates

It is now possible to specify the location where Java editor templates are applicable.

  • Statement location: The template shows up only when completing a statement.
  • Type member location: The template shows up only when completing a type member.

As a result, Content Assist (Ctrl+Space) will only show templates applicable at the current location.

Format edited lines on save

A new save action allows to format the edited lines on save. With this option enabled, format on save generates a minimal amount of changes, even on unformatted code.

Save action preference page

To enable this feature go to the Java > Editor > Save Actions preference page and select Format edited lines.

'Fix Project Setup' quick fix

If a type can not be resolved a new quick fix offers to fix the class path:

Missing type with quick fix and fix project setup dialog

For normal Java projects, the quick fix will search in other projects for the type and offer to add the JAR that contains that type to the build path. For PDE projects, information from the plug-in manifest is used to offer a new plugin dependency. Other project types can add their fix proposal through a new extension point.

Highlighting numbers in Java code

The Java editor can now show numbers with their own custom color.

Picture showing custom color for numbers

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

Javadoc shows constant value

The Javadoc hover and the Javadoc view now show the constant value of static fields.

Picture showing Javadoc hover with constant value

Mark read and write occurrences

Mark Occurrences (Alt+Shift+O) now marks read and write accesses with different colors.

Picture showing read and write accesses in the Java editor

Mark Occurrences can be enabled in the tool bar. Annotation colors are configured on the General > Editors > Text Editors > Annotations preference page

Occurrences in File improvements

Several improvements have been added to Search > Occurrences in File:

  • The quick menu (Ctrl+Shift+U) now only shows the searches applicable for the current selection. If only one search kind is possible, the shortcut will directly invoke the search.

    Picture showing the 'Occurrences in File' quick menu

  • The menu now offers all searches available by Mark Occurrences.
  • Matches are now highlighted with different colors for read and write accesses in the search view.
  • The search view offers a Link with Editor mode where the view input is connected to the current editor selection.

    Picture showing 'Link With Editor' toolbar button in the 'Occurrences result view'

Extract Class refactoring

Extract Class replaces a set of fields with a new container object. All references to the fields are updated to access the new container object. This refactoring helps to group fields which logically belong together.

The following example demonstrates how to extract the fields x,y,z to a new class Position:

Extract Class Position

The refactoring results in the creation of a new Position class which is used in the original class:

Extract Class Position result

To execute the Extract Class refactoring, select a type and invoke Refactor > Extract Class.

New Clean Ups

The following Clean Ups have been added:

  • Correct indentation: Corrects the indentation of your source code.
  • Add unimplemented methods: Adds code stubs for all unimplemented methods.

Add unimplemented methods is most useful after adding a new method to an interface. Correct indentation is also available as save action.

To clean up your code select a set of Java elements and invoke Source > Clean Up.

Refactoring flags references in binaries

Refactorings now flag references to the refactored element inside compiled class files. Such references cannot be updated and would lead to problems at run time.

Refactoring error dialog showing references in binaries

Undo format

Formatting a set of Java elements, e.g. via Package Explorer, can now be undone using Edit > Undo Format (Ctrl+Z).

Annotation formatting improvements

The Java source code formatter now provides fine-grained options for line breaks after annotations. It is possible to specify for each type of annotation if it should be followed by a line break:

  • Annotations on members:

    A member annotation

  • Annotations on parameters:

    A parameter annotation

  • Annotations on local variables:

    A local variable annotation

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

Formatter preference dialog showing the new line tab page

Java compiler on multi-CPU machines

The Eclipse Compiler for Java is now taking advantage of the multi-threading capability of multi-CPU machines. Our measurements show improvements up to 30%. Results depend on the JRE and platform used.

Support for external class folders

Class folders located outside the workspace (external) can now be added to the build path.

To add an external class folder use the Java Build Path page of the project properties, select the Libraries tab and push the Add External Class Folder button.

How set up an External Class Folder

New and improved compiler diagnostics

Several improvements have been made to the problem detection in the compiler:

  • Unnecessary declaration of thrown exception can now be ignored if it is documented with an @throws or an @exception tag.

    Screenshot of the Error/Warning preference page

    A Quick Fix (Ctrl+1) helps adding the Javadoc tag.

  • Unnecessary declaration of thrown exception can now report warnings for unused declarations of 'Exception' and 'Throwable'.

    A warning is issued if no such exception has been explicitly thrown in the code.

  • Null pointer accesses are now reported as a warning by default.
  • Unnecessary @SuppressWarnings annotations are now detected by the compiler.

    Unused Suppress Warning Example

    Note that @SuppressWarnings("all") is still silencing the warning for unnecessary @SuppressWarnings, as it is the master switch to silence all warnings.

  • Redundant superinterfaces can now be detected by the compiler.

    Example of diagnosed redundant super interface

    The unnecessary code can be removed by using Quick Fix (Ctrl+1).

You can configure this settings on the Java > Compiler > Errors/Warnings preference page.

CLDC 1.1 class file compatibility

The Java compiler can now create CLDC 1.1 compatible class files.

You can set this on the Java > Compiler preference page:

Screenshot of the Compiler preference page

Flexible ZIP archive extensions

It is now possible to add ZIP archives to the build path with file extensions other than .zip or .jar.

It is now, for example, possible to add a .rar file on the build path.

JUnit view shows execution time

The JUnit view now shows the elapsed time for test cases and test suites.

JUnit view with elapsed time

Improved Javadoc view

The Javadoc view has been improved with:

  • Icon corresponding to the current input.
  • Actions to go back and forth in the history.
  • Action to enable and disable link with selection.
  • Action to open the current input in an external browser.

Javadoc View

Rearrange content of files per drag and drop

Unsorted views like the Outline view and the Members view in the Java browsing perspective can now be used to rearrange members by drag and drop.

Outline view showing a drag and drop interaction.

Call Hierarchy view works with fields and types

The Call Hierarchy view in caller mode now works with more kinds of elements:

  • The children of a field are all members that access the field (read and write accesses)
  • The children of a type or an instance initializer are all constructors of the type

Caller Hierarchy on a field

Runnable JAR export wizard

The Runnable JAR File Export wizard can create a JAR file based on a launch configuration. The generated JAR file contains all class files from the project including class files from required JARs and projects.

The generated JAR can be executed with the command:

java -jar generated_file.jar

or, on most operating systems, by double-clicking the file.

Picture showing the runnable JAR export wizard

The export wizard can also create an ANT script which can be used to build the JAR.

Invoke File > Export... and then select the Java > Runnable JAR file wizard to create such a JAR file.

More Java search options

Type reference search can now be limited to specific match locations in the code. For example, you can find references in cast expressions, or in field and local variable types.

The following example shows how to search for all catch clauses in your code (search for references to '*' and limit to catch clauses):

Picture showing the match location selection UI

Paste creates snippet for members and statements

Paste (Ctrl+V) in the Package Explorer view now supports members and statements. Eclipse creates the required enclosing elements for you.

For example, pasting:

		List<Number> numbers;
		numbers= Arrays.asList(1, 2, 42);

into _pasted_code_ generates a Java class and main method to hold the statements:

Pasted snippet into _pasted_code_

Enhanced debug hover

When debugging, hovers for variables have been enhanced to display an object inspector. The inspector will display logical structures according to the toggle setting in the visible Variables or Expressions view.

Debug hover

Execution environment description files

An execution environment description file describes a JVM and the environment it represents (see Execution Environment Descriptions for detailed information on the file format). The file defines JVM properties such as boot path, endorsed directories, language level, executables, source attachments, and so on.

You can now add JREs to your workspace using execution environment description files from the Installed JREs preference page. Press Add and select the Execution Environment Description JRE type.

Choose the kind of JRE to add

On the following page specify an .ee file. This will create a JRE with attributes from the description file. This example shows J9 configured for Foundation 1.1.

Add JRE based on execution environmet description file

Search for installed JREs on Mac

You can now search for all installed JREs on Mac. Pressing the Search button on the Java > Installed JREs preference page will add definitions for all VMs installed in the operating system's default location (/System/Library/Frameworks/JavaVM.framework/Versions).

Search for installed JREs

Search results include launch configurations

Launch configurations now appear when searching for references to a main type. Double-clicking on the search result opens the launch dialog on that configuration.

References to a main type include launch configurations

Wait for remote debug connection

A socket listening connector has been added to the Remote Java Application launch type. This allows you to start the Java debugger listening for connection on a specific socket. The program being debugged can then be started with command line options to connect back to the debugger. Select "Standard (Socket Listen)" in the connection type drop down.

Connect tab using a socket listening connector

Default watchpoint suspend settings

You can now control the suspend settings for newly created watchpoints. A watchpoint can suspend execution when a field is accessed, modified, or both. The new preference is available on the Java > Debug preference page.

Suspend policy for watchpoints

Previous     Next