What's New in Eclipse 4.22 (JDT)

Here are descriptions of some of the more interesting or significant changes made to the Java development tools (JDT) for the 4.22 release of Eclipse. They are grouped into:

See also the Eclipse Platform What's New document for changes in the Platform.

We also recommend to read the Tips and Tricks.


Java™ 17 Support

Java 17 Java 17 is out and Eclipse JDT supports Java 17 in 4.22.

The release notably includes the following Java 17 features:
JEP 306: Restore Always-Strict Floating-Point Semantics.
JEP 406: Pattern Matching for switch (Preview).
JEP 409: Sealed Classes (Final).

Please note that preview option should be on for preview language features. For an informal introduction of the support, please refer to Java 17 Examples wiki.

JUnit

Support execution of JUnit tests that are records For Java 16 and up, JUnit tests can now be implemented as records. Right-clicking on an individual test or the record itself and selecting Run as will allow executing the test via either the JUnit Plug-in Test or JUnit Test context menu choices.

The following is an example of such a test:

JUnit test as record

JUnit 5.8.1 JUnit 5.8.1 is here and Eclipse JDT has been updated to use this version.
JUnit 4.13.2 JUnit 4.13.2 is here and Eclipse JDT has been updated to use this version.

Java Editor

Convert String concat to Text block A new cleanup and quick-assist has been added to convert appropriate String concatenations into Java Text Blocks. Appropriate String concatenations must have at least 3 non-empty substrings with one per line and the Java level must be 15 or higher. Line comments for all substrings but the last line will be lost after conversion. Spaces at the end of substrings preceding the newline will result in \s being substituted while substrings that do not end with newlines will have a \ added at the end of the line to preserve concatenation.

To apply the cleanup, select the Convert String concatenation to Text Block checkbox on the Java Feature tab in your cleanup profile:

Pref

With the cleanup, the following:

Before

Is changed to:

After

To change a single String concatenation, a quick-assist has been added that can be activated with CTRL+1 with the cursor located anywhere in the appropriate concatenation.

Surround with try-with-resources quickfix A new quickfix has been created to offer Surround with try-with-resources for resource leaks and potential resource leaks when the resource in question implements AutoCloseable.

Examples of quickfix:

Unclosed Resource

Potentially Unclosed Resource

Java Views and Dialogs

Improved lambda support in the Call Hierarchy view The Call Hierarchy view is enhanced with showing not only the callers of the lambda function, but the callers of the declaring function too.

For the following code:

Sample code

Checking the callers of the function() will show this:

CallHierarchy result

The [declaration] node in the tree is the new addition, which shows the callers of the definer() function, in this case, only the main() function.

Paste into Open Type dialog If text is pasted into the Open Type dialog then it is automatically cleaned up to the included type name by best effort.
The heuristics support:
  • Path of .java or .class files.
    C:\dev\src\p\MyType.javaMyType
  • Lines from Stacktraces.
    o.e.u.i.Workbench$$Lambda$152/0x00000001002a1928.run(Unknown Source)o.e.u.i.Workbench

Debug

Label Objects during debugging During debugging a Java application, often we have to deal with lot's of object instances, and it's not always easy to distinguish between them. That's why the experience is improved, with the ability to set a label on individual objects.

Menu item

After setting a label, everywhere the object appears it is displayed with a distinctive color and with the label:

Objects with Label