Java development tools
Java™ 14 Support |
|
Java 14 |
Java 14 is out and Eclipse JDT supports Java 14 for 4.15 via
Marketplace.
The release notably includes the following Java 14 features:
Please note that preview option should be on for preview language features. For an informal introduction of the support, please refer to Java 14 Examples wiki. |
Java Editor |
|
Subword code completion |
Content Assist now supports subword patterns, similar to Eclipse Code Recommenders and other IDEs.
For example, completing on addmouselistener proposes results like
addMouseMoveListener and addMouseWheelListener .
This feature can be enabled using the Show subword matches option on the Java > Editor > Content Assist preference page. |
Subtype code completion |
Content Assist will prioritize displaying constructor completions whose
declaring type inherits from the expected return type within the
completion context.
For example, completing on :
prioritizes constructors for
|
Option for non-blocking Java completion |
Code completion in the Java editor can now be run in a separate non-UI thread to prevent
UI freezes in case of long computations. To enable this non-blocking computation, go to Preferences >
Java > Editor > Content Assist > Advanced and check Do not block UI Thread while computing completion
proposals preference. This option is currently disabled by default.
Non-blocking completion is useful when completion proposals are long to compute, as it allows you to type or use other parts of the IDE in the meantime. Some completion participants may prevent this option from being effective (typically if the Java completion extension
doesn't declare |
Quick fix to wrap Optional statements |
A quick fix has been added to wrap an Optional statement.
The options for a primitive statement are: Example for type objects: Selecting Wrap with nullable Optional for type object results in: Example for primitive: Selecting Wrap with Optional for primitive results in: |
Simplify functional interface instances |
A new clean up has been added that simplifies the lambda expression and the method reference syntax and is enabled only for Java 8 and higher.
The clean up removes parenthesis for a single untyped parameter, return statement for a single expression and brackets for a single statement. It replaces a lambda expression by a creation or a method reference when possible. To select the clean up, invoke Source > Clean Up..., use a custom profile, and on the Configure... dialog select Simplify lambda expression and method reference syntax on the Code Style tab. For the given code: You get this after the clean up: |
Directly use Map method |
Some map manipulations are unnecessarily verbose. The new cleanup option Operate on Maps directly calls methods on a map instead of calling
the same methods on the key set or the values.
Beware! If you create |
Uppercase for long literal suffix |
A new cleanup option Use uppercase for long literal suffix has been added. It will rewrite long literals like 101l with an uppercase L like 101L to avoid ambiguity.
|
Surround with "try-with-resources" block |
Corresponding to the quick fix which will surround a selection with a "try-with-resources" block, a new
action has been added to the Surround With menu.
For example, selecting the lines as shown: and right-clicking and selecting Surround With -> Try-with-resources Block results in: |
Quick fixes for module-info Javadoc |
Quick fixes have been added to fix the missing and duplicate @provides and @uses Javadoc tags in a module-info file.
|
No more spurious semicolon from import completion | Almost 18 years ago, it was reported that completion for imports adds an unnecessary semicolon if one already exists (like when changing an existing import). Now this extra semicolon is no longer inserted. |
Java Compiler |
|
Warn when legacy code can taint null-checked values |
When using null-annotations for advanced null analysis, it is inherently tricky to combine your
code with "legacy" code that has no null annotations and has not been blessed by such analysis.
Previously, Eclipse would only warn you when you obtain a dubious value from a legacy API,
but it would keep silent in the opposite case: passing a value of an annotated type
into legacy API. Still in specific situations this can cause a
The console shows an exception thrown from within your checked main method (see the
class-level
Hint: The shown code assumes the list
By default this problem is raised at level
|
Improved Resource leak analysis |
Resource leak analysis has been improved in several ways.
Most importantly, the analysis now consistently considers resources (=values of type makePrintWriter("/tmp/log.txt").printf("%d", 42); // a PrintWriter is never closed!
Second, resource leak analysis now leverages knowledge about well-known resource classes that support fluent programming,
i.e., instance methods which return
The following example is now understood to be safe, because analysis understands that the resource
returned by PrintWriter pw = new PrintWriter("/tmp/log.txt"); pw.printf("%d", 42).append(" is the answer").close(); Generally, resource leak analysis was made more precise regarding several specific situations. |
Java Formatter |
|
Java formatter application requires a workspace |
The Java formatter application will provide a sensible error message if a workspace
is required but not provided (-data command line option). This also enables
the -help option to be run on the formatter without a workspace specified.
A new bundle services the |
Debug |
|
Functional debug expressions |
Lambda expressions and method references are now supported in debug expressions, such as in the Expressions view
and in breakpoint condition expressions.
Some limitations apply: The feature should be considered a MVP (Minimally Viable Product). It is not yet possible to reference non-public fields and methods of the enclosing class. The evaluation may not work in system classes and some generic contexts. |
JDT Developers |
|
New bundle org.eclipse.jdt.core.formatterapp |
The entry point of the org.eclipse.jdt.core.JavaCodeFormatter application has been
moved to a new bundle, org.eclipse.jdt.core.formatterapp .
|