Eclipse Support for Java 8

Last week Java 8 was launched and moments later the Eclipse support for Java 8 was announced. To help celebrate the launch, we had an entire Java 8 Day at EclipseCon 2014, which included sessions from both Java and Eclipse engineers. Highlights for me included hearing Alex Buckley describe the Road to Lambda, listening to John Arthorne talk about API Design in Java 8 and watching the Eclipse Java Development Tools (JDT) Team present all the great work they did on Java 8 Tooling in Eclipse.

Java 8 is available as an update for Eclipse Kepler (2013 Release) and is now available nightly / integration builds towards Eclipse Luna (2014 Release). For details about how to get Java 8 support in Eclipse, please read to the bottom of this post.

New and Noteworthy

For those of you who were not lucky enough to join us in San Francisco, here is a summary of the Eclipse Support for Java 8.

Screen Shot 2014-03-24 at 3.45.13 PM

The Eclipse Java Compiler (EJC) now supports Java 8 and the tools are well integrated. There are quick-fixes, for converting anonymous inner classes (with a single method — i.e. functional interfaces) to a lambda expression:

Screen Shot 2014-03-24 at 3.43.37 PM

As well as ones for converting back, or even changing the body expression to a block (ctrl+1):

Screen Shot 2014-03-24 at 3.48.02 PM

And in-line refactoring support :

Screen Shot 2014-03-24 at 6.56.59 PM

There are Code Formatter options for lambda expressions such as ones that describe how the expression should be wrapped:

Screen Shot 2014-03-24 at 3.50.40 PM

And code clean-up actions which will convert the uses of anonymous classes to lambdas where possible. Simple enable this, and select Source -> Clean Up to automatically update your current code to use lambdas.

Screen Shot 2014-03-24 at 3.55.44 PM

The debugger supports breakpoints in lambdas as well as the variable view, and stack frame inspection:

debug

While lambda support was clearly the most visible change in Java 8, there are a number of other features too. Features such as default methods (method bodies in your interfaces), better type inference and effectively final variables are all supported:

Screen Shot 2014-03-26 at 9.10.31 AM

Finally, Java 8 supports type annotations and Eclipse ships with a set of annotations for null analysis. For example, you can specify that a List should never be null, and each element of the list should also never be null. The JDT will provide compile time type checking to ensure this constraint holds.

nonnull

This provides API designers with the facilities to create better interfaces with stricter rules about what can be passed to and returned from an API.

api

Java 8 represents one of the biggest Java releases ever. The JDT team should be really proud of the great work they did to support Java 8 in Eclipse.

For more information on Eclipse and Java 8, checkout Holger’s article on Java 8 and SWT.

Feel free to follow me (@irbull) on Twitter for more Eclipse updates.

[ Looking for tools? See our Eclipse Tools page. | Managing your Eclipse workspaces is easier with Yoxos. Create a free profile now. ]

Getting Java 8

Java 8 is available in builds towards Eclipse Luna (2014 Release coming in June) and as an update for Eclipse Kepler (2013 Release). To develop Java 8 applications, you will first need to install a Java 8 JDK. Additionally, please use an Eclipse version Luna or later