Java development tools
Java™ 16 Support |
|
Java 16 |
Java 16 is out and Eclipse JDT supports Java 16 in 4.20.
The release notably includes the following Java 16 features:
Please note that preview option should be on for preview language features. For an informal introduction of the support, please refer to Java 16 Examples wiki. |
JUnit |
|
BREE update for JDT JUnit runtime bundles |
The bundle required execution environment (BREE) for the org.eclipse.jdt.junit.runtime and org.eclipse.jdt.junit4.runtime bundles is now JavaSE-1.8.
|
Java Editor |
|
Better type for the local variable creation quick fix |
The quick fix Create a new local variable has been enhanced. When it creates a variable that is the expression on which a foreach loop iterates, its type is an array of the type of the loop parameter:
For the given code: One gets: |
Use instanceof clean up |
A new clean up has been added that uses an instanceof expression to check an object against a hardcoded class.
The expression must be a supertype of the targeted class. To apply the clean up, select Use instanceof keyword instead of Class.isInstance() check box on the Code Style tab in your clean up profile. For the given code: One gets: |
Operand factorization clean up |
A new clean up has been added that replaces (X && Y) || (X && Z) by (X && (Y || Y)) .
The operands must be passive and primitive. To apply the clean up, select Replace (X && Y) || (X && Z) by (X && (Y || Z)) check box on the Duplicate code tab in your clean up profile. For the given code: One gets: |
Pull out a duplicate 'if' from an if/else clean up |
A new clean up has been added that moves a duplicate inner if condition around an outer if condition.
The inner
The To apply the clean up, select Pull out a duplicate 'if' from an if/else check box on the Duplicate code tab in your clean up profile. For the given code: One gets: |
One if rather than duplicate blocks that fall through clean up |
A new clean up has been added that merges consecutive if statements with same code block that end with a jump statement.
To apply the clean up, select Single 'if' statement rather than duplicate blocks that fall through check box on the Duplicate code tab in your clean up profile. For the given code: One gets: |
Uses String.isBlank() clean up |
A new clean up has been added that replaces the check of the emptiness of String.strip() by the use of String.isBlank() .
It avoids the cost of the creation of a stripped string. You may use Java 11 or higher to use it.
In order to apply this cleanup also to
But watch out, To apply the clean up, select String.isBlank() rather than String.strip().isEmpty() check box on the Optimization tab (the Performance tab in Eclipse 2021-09) in your clean up profile. For the given code: One gets: |
valueOf() rather than instantiation clean up |
A new clean up has been added that replaces unnecessary primitive wrappers instance creations by using static factory methods (valueOf() ).
It dramatically improves the space performance. To apply the clean up, select valueOf() rather than instantiation check box on the Optimization tab (the Performance tab in Eclipse 2021-09) in your clean up profile. For the given code: One gets: |
Primitive rather than wrapper clean up |
A new clean up has been added that replaces a primitive wrapper object by the primitive type when an object is not necessary.
The variable must be not To apply the clean up, select Primitive type rather than wrapper class check box on the Optimization tab (the Performance tab in Eclipse 2021-09) in your clean up profile. For the given code: One gets: |
Redundant truth clean up |
A new clean up has been added that directly checks boolean values instead of comparing them with true /false .
The operator can be equals, not equals or XOR.
The constants can be a literal or a To apply the clean up, select Boolean value rather than comparison check box on the Unnecessary Code tab in your clean up profile. For the given code: One gets: |
Implicit comparator clean up |
A new clean up has been added that removes the comparator declaration if it is the default one.
The declared comparator should be an equivalent to the natural order.
It removes anonymous class, lambda, To apply the clean up, select Use implicit comparator when possible check box on the Unnecessary Code tab in your clean up profile. For the given code: One gets: |
Initialize array with curly clean up |
A new clean up has been added that replaces the new instance syntax by curly brackets to create an array.
It must be an initialization of a declaration. The declaration must have the same type. To apply the clean up, select Create array with curly when possible check box on the Unnecessary Code tab in your clean up profile. For the given code: One gets: |
Remove variable assignment before return clean up |
A new clean up has been added that removes unnecessary local variable declaration or unnecessary variable assignment before a return statement.
An explicit type is added for arrays. To apply the clean up, select Remove variable assignment before return check box on the Unnecessary Code tab in your clean up profile. For the given code: One gets: |
Replace System.getProperty() calls clean up |
A new clean up has been added that replaces certain System.getProperty() calls with alternative Java method calls or constants instead.
Using these calls/constants may end up using system defaults (e.g. system default file separator) and thus can no longer be overridden at runtime.
To apply the clean up, select Replace system property with constant check box on the Java Feature tab in your clean up profile. This enables you to check one or more sub-options: File separator, Path separator, Line separator, File encoding, or Boolean property. The last option is used for arbitrary boolean options specified by -Dsome-arbitrary-option. For the given code: One gets: |
Java Views and Dialogs |
|
Differentiate search filter for normal imports from static imports |
The Search view now supports a new filter dedicated for static imports. Consequently, the existing imports filter is dedicated for non-static imports only.
As a result, you will now by default find statically imported references of a class or an interface.
|
Create module-info.java option during New Java Project creation |
Create module-info.java option has been moved to the first page of New Java Project creation wizard.
This option will be enabled only for Java projects with JRE 9 or above.
New Java Project creation wizard will also remember the previous choice made by the user and select this option by default accordingly.
|
Default Java cleanup profile of Eclipse has been updated |
The default cleanup profile of the Java development tools has been updated to include more cleanups. All included cleanups have been well tested and proven to be stable in the Eclipse code base.
Please see the preference under Java > Clean-up for details.
|
Debug |
|
Copy Run Configuration item details |
A new Copy button has been added to the Dependencies/Classpath tab of Run Configuration dialog.
This can be used to copy the details of the selected item.
|
Debug hover for chain of variables |
When hovering over chain of variables, the debug hover will now show the variable value under the cursor.
It even works for array length.
|