Java development tools
Java™ 17 Support
Java 17 is out and Eclipse JDT supports Java 17 in 4.21 via
The release notably includes the following Java 17 features:
|mockito ArgumentMatchers.* added to favorites in Java tooling||
Mockito based tests frequently use
|Use StringBuilder instead of StringBuffer clean up||
A new clean up has been added that converts code to use
There is a sub-option where changes will only occur to local variables which is on by default. When this sub-option is on, changes will only occur to
When the option is selected and the sub-option for local variables is off,all usage of
To apply the clean up, select the Use StringBuilder instead of StringBuffer check box on the Performance tab in your clean up profile. To specify just for local variables, select the Only for local variables check box found just below.
For the given code:
|Convert while to do/while||
A new quick-assist has been added to convert appropriate while loops into do/while loops. Appropriate while loops require the first evaluation of the while expression is guaranteed to be true and that the evaluation is passive.
For the following loop:
One is offered:
|Extract Superclass Enhancement||
The Extract Superclass refactoring has been enhanced to support movement of uninitialized non-static final fields. In the past, a warning was issued for extracting uninitialized non-static final fields as the resultant code would be in error. The refactoring has been enhanced to add additional parameters to the moved constructors and to pass initialization values from the original class constructors.
For the following class:
Extracting to Superclass and choosing all fields, one gets:
|Raw Paste||A new menu item has been added for doing a raw paste when editing Java files. The menu item Raw Paste can be found in the Edit pull-down menu and by right-clicking in the edit window to bring up the context-menu. The menu item performs a paste action but toggles off the smart insert feature, if required, and restores it, if necessary, after the paste. For end-users in smart insert mode, this is the same as doing a Shift+Ctrl+Insert followed by Ctrl+V, followed by Shift+Ctrl+Insert to retoggle into smart insert mode again.|
|Default Type Filters||
Default values have been added to the Java > Appearance > Type Filters preferences. Types matching these filters will be excluded
from appearing in the Open Type dialog, content assist, quick fix, and organize imports. These filter patterns do not affect the Package Explorer and Type Hierarchy views.
|Change project compliance and JRE on using multi-constant case labels||
A new quick fix (Ctrl+1) has been added to change the project compliance and JRE when multi-constant case labels
are used in a project below Java 14:
|Quick fix to declare sealed interface as super interface||
You can use the following quick fix (Ctrl+1) to declare a sealed interface as super interface of its permitted types:
|Quick fix to declare sealed class as super class||
You can use the following quick fix (Ctrl+1) to declare a sealed class as super class of its permitted classes:
|Quick fix to add the sub type to permitted types of sealed super type||
You can use the following quick fix (Ctrl+1) to add a sub type to permitted types of a sealed super type:
|Find external annotations anywhere||
External annotations, which are used for annotation based null analysis, can now be associated
to unannotated classes more freely.
Previously, all external annotations where declared per build path entry. I.e., whenever a project of yours uses a library for which external annotations exist, you would need to explicitly declare where the corresponding external annotations for this particular library can be found.
A new compiler preference has been added by which you can instruct the compiler to search for external annotations in all build path locations of the current project.
When enabled, this strategy will be applied to all class files encountered during compilation.
Some examples, where this option is useful:
For batch compilation a corresponding option already exists. To match the above strategy in CI-builds,
just add the following to the compiler command line (verbatim):
|Evaluate variables in current execution stack||
In debug mode, regardless of the selected stack frame now you can evaluate variables which are
in the scope of the current execution stack frame and stack frames below it which are defined in
the current focused java class.