Skip to main content

Java development tools

Java™ 17 Support

Java 17 Java 17 is out and Eclipse JDT supports Java 17 in 4.21 via Marketplace.

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.


mockito ArgumentMatchers.* added to favorites in Java tooling Mockito based tests frequently use org.mockito.ArgumentMatchers.*. This has been added to the Java favorites in the preferences under Java > Editor > Content Assist > Favorites. This way the organize imports action in the IDE will automatically add static imports for these classes if you use them in your tests.

Java Editor

Use StringBuilder instead of StringBuffer clean up A new clean up has been added that converts code to use StringBuilder (added in Java 1.5) rather than StringBuffer which has synchronized methods and is slower than using StringBuilder.

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 StringBuffer variables that are local to a method. When a method calls other methods with such variables or assigns to/from fields/parameters, the method contents will not be converted. It is permitted to append StringBuffer fields or parameters to local StringBuffer variables which can then still be converted to StringBuilder.

When the option is selected and the sub-option for local variables is off,all usage of StringBuffer in the selected files are changed to StringBuilder regardless of usage. It should be noted that in this case, the clean up will not track down non-selected classes and methods that are referenced and might require changes to compile successfully.

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:


One gets:


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:

Java Compiler

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:

  • A project A contains generated sources (in a separate source folder), which are decorated using external annotations in the same project. When project A ships a jar containing also the external annotations, any client of A will immediately see the generated classes with their external annotations applied.
  • When dedicated jars have been created, each containing external annotations for a set of libraries, you only have to add these annotation jars to your build path and enable the new option, without worrying which annotation jar corresponds to which individual dependency (dependencies). The compiler will match external annotations to class files with no further help.

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):
-annotationpath CLASSPATH


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.

screenshot showing evaluation result

Previous Up Next

Back to the top