JDT UI/Java8

This page tracks the work in progress to add Java™ 8 support (mainly jsr308 "Type Annotations" and jsr335 "Lambda Expressions") into Eclipse JDT UI. See JDT Core/Java8 for the work in the JDT Core plug-ins.

Note: This is an internal project page that may be horribly out of date.

check code that walks the parent chain to find the enclosing Block or BodyDeclaration

Method References

IMPORTANT NOTE

The following lines must be added in all headers of modified files for Java™ 8 implementation:

* This is an implementation of an early-draft specification developed under the Java
* Community Process (JCP) and is made available for testing and evaluation purposes
* only. The code is not compatible with any specification of the JCP.
*

Use the following @since tag on all newly added members: "3.9 BETA_JAVA8"

How to set up the IDE

Early access binaries

UI decisions

TYPE_USE annotations

ITypeBindings can now carry TYPE_USE annotations. API of ITypeBindings#equals needs to be updated and we eventually need to replace usages of == with #equals(Object).

=> Conclusion: ITypeBindings don't carry TYPE_USE annotations.

Should TYPE_USE annotations show up in the Java model (IJavaElements)? The intention of the Java model is to provide a high-level structure for rendering elements in an outline and to serve as enclosing elements in search results. TYPE_USE annotations don't show up in type signatures and the compiler doesn't consult them. They are second-class citizens. The Java model cannot contain every detail of an element (e.g. it also doesn't contain comments). Furthermore, it's not clear how TYPE_USE annotations should be represented. They can't be part of a signature.

=> Conclusion: IJavaElements don't carry TYPE_USE annotations.

Lambda expressions in the Java model

Currently, anonymous classes are represented in the Java model. Should lambda expressions and method references also be part of the model?
The problem with that is that lambda expressions are perceived more lightweight than anonymous classes, so lambda expressions will be used much more frequently. Method references are another form of implicit class declarations, since some forms already bind a receiver object.

Anonymous classes must be part of the Java model, because they can define multiple members (fields/methods) that should be visible in an Outline and that should support operations like "Open Super Implementation". OTOH, lambda expressions and method references don't have sub-members. However, a lambda expression can contain anonymous and local classes, and the lambda expression itself would be interesting as the enclosing element in a search result.

=> Conclusion: Lambda expressions are currently not represented in the Java model but might be added later.

Things to remember/caveats

Goal of the first pass is to make Eclipse work with the new language features. For more advanced support (new quick fixes / refactorings / templates / ...), please file an enhancement request with the [1.8] tag.

Bugs that went into the BETA_JAVA8 branch should be RESOLVED/FIXED with Target Milestone "BETA_JAVA8" and the [1.8] tag in front of the summary.

For ASTNode changes:

Search for references to a changed AST Node and update code that relies on the concrete structure

in most cases, JDT UI only supports ASTs with the latest AST level (internal ASTProvider.SHARED_AST_LEVEL)

we only do AST#apiLevel() checks where old ASTs can be passed in via JDT UI APIs:

Annotated array dimensions are not clearly defined by the current JLS8. See this post. The assumption is that array dimensions are nested like this, from innermost (element type) to outermost:

element type (with annotations just in front of the type)

extra dimensions, from left to right

type dimensions, from left to right

TODOs

'default' flag:

show in the UI?

update JdtFlags?

The ITypeBinding of a TYPE_USE-annotated expression (e.g. ClassInstanceCreation or reference to a variable) doesn't contain the TYPE_USE annotations. References to "String s" and "@NonEmpty String ns" have identical type bindings. Should TYPE_USE annotations show up in reference bindings? Note that for some expressions, the annotated type is not defined by jsr 308, e.g. for the conditional expression here: