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.
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:
As well as ones for converting back, or even changing the body expression to a block (ctrl+1):
And in-line refactoring support :
There are Code Formatter options for lambda expressions such as ones that describe how the expression should be wrapped:
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.
The debugger supports breakpoints in lambdas as well as the variable view, and stack frame inspection:
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:
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.
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.
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.
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