| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta name="copyright" content="Copyright (c) Eclipse contributors and others 2018-2020. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page."/> |
| <meta http-equiv="Content-Language" content="en-us"/> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| <link rel="STYLESHEET" href="news.css" type="text/css"/> |
| <style type="text/css"> |
| body {max-width: 900px;} |
| table.news col.title {width: 30%;} |
| /*img {max-width: 520px;}*/ |
| table.news {table-layout: fixed; border-collapse: collapse; width: 100%;} |
| table.news td {border-top: solid thin black; padding: 10px; overflow: visible;} |
| table.news tr {vertical-align: top;} |
| table.news tr td.section {font-size: 20px; font-weight: bold;} |
| table.news tr td.title {vertical-align: top; font-weight: bold;} |
| table.news tr td.content {vertical-align: top;} |
| ul {padding-left: 13px;} |
| </style> |
| <title>Eclipse Project 4.18 - New and Noteworthy</title> |
| </head> |
| |
| <body> |
| <h2>Java development tools</h2> |
| <ul> |
| <!--<li><a href="#JavaXX">Java™ XX Support</a></li>--> |
| <li><a href="#JUnit">JUnit</a></li> |
| <li><a href="#JavaEditor">Java Editor</a></li> |
| <li><a href="#JavaViewsAndDialogs">Java Views and Dialogs</a></li> |
| <li><a href="#JavaFormatter">Java Formatter</a></li> |
| <li><a href="#Debug">Debug</a></li> |
| <!--<li><a href="#JDTDev">JDT Developers</a></li>--> |
| </ul> |
| |
| <!-- ****************** START OF N&N TABLE ****************** --> |
| <table class="news"> |
| <colgroup> |
| <col class="title" /> |
| <col /> |
| </colgroup> |
| <tbody> |
| |
| <!-- ******************* Java XX Support ************************************* --> |
| <!-- |
| <tr> |
| <td id="JavaXX" class="section" colspan="2"> |
| <h2>Java™ XX Support </h2> |
| </td> |
| </tr> |
| --> |
| <!-- ******************* End of Java XX Support ************************************* --> |
| |
| <!-- ******************* JUnit ************************************* --> |
| <tr> |
| <td id="JUnit" class="section" colspan="2"> |
| <h2>JUnit</h2> |
| </td> |
| </tr> |
| <tr id="junit-5.7"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567357 --> |
| <td class="title"><a href="#junit-5.7">JUnit 5.7</a></td> |
| <td class="content"> |
| <a href="https://junit.org/junit5/docs/current/release-notes/index.html#release-notes-5.7.0/">JUnit 5.7</a> is here and Eclipse JDT has been updated to use this version. |
| </td> |
| </tr> |
| <!-- ******************* End of JUnit ************************************* --> |
| |
| <!-- ******************* Java Editor ************************************* --> |
| <tr> |
| <td id="JavaEditor" class="section" colspan="2"> |
| <h2>Java Editor </h2> |
| </td> |
| |
| </tr> |
| <tr id="completion-overwrites"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=423642 --> |
| <td class="title"><a href="#completion-overwrites">Completion overwrites in Java editor</a></td> |
| <td class="content"> |
| The <b>Java Editor</b> now uses Completion overwrites as the default. |
| If Completion overwrites is on, the completion text replaces the characters following the caret position until the end of the word. |
| If Completion inserts is on, the completion text is inserted at the caret position, so it never overwrites any existing text. |
| Note that pressing <code>Ctrl</code> when applying a completion proposal toggles between the two insertion modes. |
| <p>You can change the default in the <b>Java > Editor > Content Assist</b> preference page.</p> |
| </td> |
| </tr> |
| |
| <tr id="param-best-guessed"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=433121 --> |
| <td class="title"><a href="#param-best-guessed">Insert best guessed parameters in Java editor</a></td> |
| <td class="content"> |
| Instead of simply inserting the method parameter names as placeholders, when a method is completed, |
| the <b>Java Editor</b> now inserts the best guessed parameters by default. |
| <p>You can change the default in the <b> |
| Java > Editor > Content Assist</b> preference page. |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="quick-assist-new-impl"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=565600 --> |
| <td class="title"><a href="#quick-assist-new-impl">Quick assist to create new implementation</a></td> |
| <td class="content"> |
| Invoking the <b>Quick Assist (Ctrl+1)</b> to create new implementation on an interface or abstract class declaration launches the <b>New Java Class</b> wizard: |
| <p> |
| <img src="images/quick_assist_interface.png" alt="" /> |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="quick-fixes-permitted-types"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=564834, https://bugs.eclipse.org/bugs/show_bug.cgi?id=565420 --> |
| <td class="title"><a href="#quick-fixes-permitted-types">Quick fixes on permitted types</a></td> |
| <td class="content"> |
| You can add <code>sealed</code>, <code>non-sealed</code>, or <code>final</code> modifiers on permitted type declarations, as applicable, using the new <b>Quick Fixes (Ctrl+1)</b>. |
| <p> |
| On a permitted class declaration: |
| </p> |
| <p> |
| <img src="images/permitted_class.png" alt="" /> |
| </p> |
| <p> |
| On a permitted interface declaration: |
| </p> |
| <p> |
| <img src="images/permitted_interface.png" alt="" /> |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="switch-expressions"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=545342 --> |
| <td class="title"><a href="#switch-expressions">Convert to switch expression</a></td> |
| <td class="content"> |
| A new quick assist and clean up has been added that converts switch statements to switch expressions (Java 14 or higher) where possible. |
| <p> |
| Switch statements that use control statements such as nested switch statements, if/else blocks, for/while loops are not considered as is the case |
| for return/continue statements. All cases |
| of the switch statement must either have a last assignment statement that sets the same variable/field as other cases, or else has a <b>throw</b> statement. |
| Fall-through is allowed between cases but only if there are no other statements in between. The |
| switch statement must have a <b>default</b> case unless the switch expression |
| is an enum type and all possible enum values are represented in the cases. |
| </p> |
| <p> |
| To apply the quick assist, press <b>Ctrl+1</b> on the target switch statement and select <b>Convert to switch expression</b>, if offered. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Convert to switch expression</b> check box on the <b>Code Style</b> tab (or the <b>Java Feature</b> tab starting from Eclipse 2021-03). |
| </p> |
| <p><img src="images/switch-expressions-preferences.png" alt="Preferences" width="800"/></p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/switch-expressions-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/switch-expressions-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="else-if"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567779 --> |
| <td class="title"><a href="#else-if">Uses the else-if pseudo keyword</a></td> |
| <td class="content"> |
| A new clean up has been added that combines nested <code>if</code> statement in <code>else</code> block to <code>else if</code>. |
| <p> |
| Beware for any comments after the <code>else</code> keyword. It will be lost. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Combine nested 'if' statement in 'else' block to 'else if'</b> check box on the <b>Code Style</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/else-if-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/else-if-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="bitwise-expressions"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567298 --> |
| <td class="title"><a href="#bitwise-expressions">Bitwise expressions in comparisons</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces the <code>></code> operator with <code>!=</code> when the comparison |
| expression has a bitwise expression operand and a <code>0</code> operand. |
| <p> |
| This resolves an anti-pattern for such kind of comparisons, which can also be a bug when the bitwise expression |
| is involving a negative constant value. This code smell is further described by the FindBugs project |
| as bug description <a href="http://findbugs.sourceforge.net/bugDescriptions.html#BIT_SIGNED_CHECK">"BIT: Check for sign of bitwise operation"</a>. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog select <b>Compare with != 0 for bitwise expression</b> on the <b>Code Style</b> tab (or the <b>Source fixing</b> tab starting from Eclipse 2021-03). |
| </p> |
| <p><img src="images/bitwise-expressions-preferences.png" alt="Preferences" width="620"/></p> |
| <table> |
| <tr><td style="border-top: none">For the given code:</td><td style="border-top: none">You get this after the clean up:</td></tr> |
| <tr> |
| <td style="border-top: none"><img src="images/bitwise-expressions-before.png" alt="Before" width="290"/></td> |
| <td style="border-top: none"><img src="images/bitwise-expressions-after.png" alt="After" width="290"/></td> |
| </tr> |
| </table> |
| <!-- |
| For the given code: |
| <p><img src="images/bitwise-expressions-before.png" alt="Before" width="350"/></p> |
| You get this after the clean up: |
| <p><img src="images/bitwise-expressions-after.png" alt="After" width="350"/></p> |
| --> |
| </td> |
| </tr> |
| |
| <tr id="pull-up-assignment"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568188 --> |
| <td class="title"><a href="#pull-up-assignment">Pull up assignment</a></td> |
| <td class="content"> |
| A new clean up has been added that moves assignments inside an <code>if</code> condition above the <code>if</code> node. |
| <p> |
| It improves the readability of the code. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Pull up assignment</b> check box on the <b>Code Style</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/pull-up-assignment-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/pull-up-assignment-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="use-switch"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568611 --> |
| <td class="title"><a href="#use-switch">Use switch</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces <code>if</code>/<code>else</code> <code>if</code>/<code>else</code> blocks to use <code>switch</code> when possible. |
| <p> |
| It converts to <code>switch</code> when there are more than two cases. |
| </p> |
| <p> |
| It does not convert if the discriminant can be <code>null</code>, that is to say only primitive. |
| </p> |
| <p> |
| It does a variable conflict analyze. |
| </p> |
| <p> |
| The case value can be literals or constants. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Convert if/else if/else chain to switch</b> check box on the <b>Code Style</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/use-switch-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/use-switch-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="add-remove"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567335 --> |
| <td class="title"><a href="#add-remove">Add elements in collections without loop</a></td> |
| <td class="content"> |
| A new clean up has been added that uses <code>Collection.addAll()</code> or <code>Collections.addAll()</code> instead of a <code>for</code> loop. |
| <p> |
| It refactors <code>for</code> loops with index, <code>for</code> loops with iterator and <code>foreach</code> loops. |
| </p> |
| <p> |
| If the source is an array, the list is raw, and the Java version is 1.5 or higher, we use Arrays.asList() to handle the erasure type. |
| It doesn't decrease the performance. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Add elements in collections without loop</b> check box on the <b>Code Style</b> tab. |
| </p> |
| <p><img src="images/add-remove-preferences.png" alt="Preferences" width="800"/></p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/add-remove-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/add-remove-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="ternary-operator"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568822 --> |
| <td class="title"><a href="#ternary-operator">Use ternary operator</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces <code>(X && Y) || (!X && Z)</code> by <code>X ? Y : Z</code>. |
| <p> |
| The operands must be passive and boolean. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Replace (X && Y) || (!X && Z) by X ? Y : Z</b> check box on the <b>Duplicate Code</b> tab. |
| </p> |
| <p><img src="images/ternary-operator-preferences.png" alt="Preferences" width="800"/></p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/ternary-operator-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/ternary-operator-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="xor"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568615 --> |
| <td class="title"><a href="#xor">Use '==' or '^' on booleans</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces <code>(X && !Y) || (!X && Y)</code> by <code>X ^ Y</code> and replaces <code>(X && Y) || (!X && !Y)</code> by <code>X == Y</code>. |
| <p> |
| It only works on boolean. |
| </p> |
| <p> |
| It works with lazy or eager operators. |
| </p> |
| <p> |
| The operands must be passive. |
| </p> |
| <p> |
| It does not matter an operand is on the left or right. |
| </p> |
| <p> |
| It does a deep negation expression analyze. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Use '==' or '^' on booleans</b> check box on the <b>Duplicate Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/xor-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/xor-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="redundant-falling-blocks"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567553 --> |
| <td class="title"><a href="#redundant-falling-blocks">Redundant falling through blocks</a></td> |
| <td class="content"> |
| A new clean up has been added that detects a list of statements that ends with a jump statement (<code>return</code>, <code>break</code>, <code>continue</code> or <code>throw</code>), and has the same list of statements below that. |
| <p> |
| It detects similar statements. It also checks that the declarations of the variables in the statements are the same. It looks for redundant statements in <code>if</code>, <code>else</code>, <code>catch</code> and <code>finally</code> but not in loops. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Remove redundant end of block with jump statement</b> check box on the <b>Duplicate Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/redundant-falling-blocks-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/redundant-falling-blocks-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="if-condition"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567599 --> |
| <td class="title"><a href="#if-condition">Redundant if condition</a></td> |
| <td class="content"> |
| A new clean up has been added that removes a condition on an <code>else</code> that is negative to the condition of the previous <code>if</code>. |
| <p> |
| The condition must be passive. The removed code should not throw an expected exception. The cleanup uses a deep condition comparison algorithm. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Redundant if condition</b> check box on the <b>Duplicate Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/if-condition-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/if-condition-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="hash"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567692 --> |
| <td class="title"><a href="#hash">Use Objects.hash()</a></td> |
| <td class="content"> |
| A new clean up has been added that rewrites Eclipse-autogenerated <code>hashCode()</code> method by Eclipse-autogenerated <code>hashCode()</code> method for Java 7 using <code>Objects.hash()</code>. |
| <p> |
| Let's remind that you can autogenerate your <code>hashCode()</code> and <code>equals()</code> methods by right-clicking on your class, selecting <b>Source</b> and clicking on <b>Generate hashCode() and equals() methods...</b>. |
| Since Eclipse 2018-09, <a href="https://www.eclipse.org/eclipse/news/4.9/jdt.php#java7-hashcode-equals">a checkbox allows you to generate your methods using Java 7 API</a>. This cleanup rewrites your method as if it has been generated using this option. |
| </p> |
| <p> |
| This clean up does not generate again your method from scratch, it rewrites it using a more modern syntax. That is to say, if your method is missing or voluntary does not process a field, this field still won't be processed. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Use Objects.hash()</b> check box on the <b>Unnecessary Code</b> tab (or the <b>Java Feature</b> tab starting from Eclipse 2021-03). |
| </p> |
| <p><img src="images/hash-preferences.png" alt="Preferences" width="800"/></p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/hash-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/hash-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="string-join"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567794 --> |
| <td class="title"><a href="#string-join">Use String.join()</a></td> |
| <td class="content"> |
| A new clean up has been added that uses <code>String.join()</code> when possible. |
| <p> |
| It detects all types of for loops. The delimiter can be added before or after. The condition can be a boolean or an index comparison. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Use String.join()</b> check box on the <b>Unnecessary Code</b> tab (or the <b>Java Feature</b> tab starting from Eclipse 2021-03). |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/string-join-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/string-join-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="arrays-fill"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567264 --> |
| <td class="title"><a href="#arrays-fill">Use Arrays.fill()</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces for loops to use <code>Arrays.fill()</code> where possible. |
| <p> |
| The value must be hard-coded. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Use Arrays.fill()</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/arrays-fill-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/arrays-fill-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="redundant-null-check"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568412 --> |
| <td class="title"><a href="#redundant-null-check">Evaluate without null check</a></td> |
| <td class="content"> |
| A new clean up has been added that removes redundant null checks. |
| <p> |
| It removes null check on value before <code>equals()</code> or <code>equalsIgnoreCase()</code> method and before <code>instanceof</code> expression. |
| </p> |
| <p> |
| It only removes redundant passive expressions. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Evaluate without null check</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/redundant-null-check-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/redundant-null-check-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="double-negation"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568409 --> |
| <td class="title"><a href="#double-negation">Avoid double negation</a></td> |
| <td class="content"> |
| A new clean up has been added that reduces double negation in <code>boolean</code> expression. |
| <p> |
| It removes negations on both operands in an equality/difference operation. |
| </p> |
| <p> |
| It prefers equality/difference operation rather than negated operand. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Double negation</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/double-negation-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/double-negation-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="redundant-comparison-statement"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567567 --> |
| <td class="title"><a href="#redundant-comparison-statement">Redundant comparison statement</a></td> |
| <td class="content"> |
| Removes useless bad value checks before assignments or <code>return</code> statements. Such useless bad value checks are comparing an expression against bad value, then either assigning bad value or the expression depending on the result of the bad value check. It is simpler to directly assign the expression. |
| <p> |
| The expression should be passive. |
| </p> |
| <p> |
| The excluded value should be hard coded. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Remove redundant comparison statement</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/redundant-comparison-statement-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/redundant-comparison-statement-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="redundant-super"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567148 --> |
| <td class="title"><a href="#redundant-super">Unnecessary super() call</a></td> |
| <td class="content"> |
| A new clean up has been added that removes call to <code>super</code> constructor with empty arguments. |
| <p> |
| Such a call is redundant. See JLS section 12.5 for more info. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Remove redundant super() call in constructor</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/redundant-super-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/redundant-super-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="collection-cloning"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=566996 --> |
| <td class="title"><a href="#collection-cloning">Initialize collection at creation</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces the creation of a new <code>Collection</code>, then invoking <code>Collection.addAll()</code> on it, by the creation of the new <code>Collection</code> with the other <code>Collection</code> as parameter. |
| <p> |
| Only well known collection classes are refactored to avoid behavior changes. The cleanup is enabled only if there is no useful instantiation parameters. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Initialize collection at creation</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/collection-cloning-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/collection-cloning-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="map-cloning"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567262 --> |
| <td class="title"><a href="#map-cloning">Initialize map at creation</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces creating a new <code>Map</code>, then invoking <code>Map.putAll()</code> on it, by creating the new <code>Map</code> with the other <code>Map</code> as parameter. |
| <p> |
| Only well known map classes are refactored to avoid behavior changes. The cleanup is enabled only if there is no useful instantiation parameters. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Initialize map at creation</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/map-cloning-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/map-cloning-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="overridden-assignment"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567977 --> |
| <td class="title"><a href="#overridden-assignment">Remove overridden assignment</a></td> |
| <td class="content"> |
| A new clean up has been added that removes passive assignment when the variable is reassigned before being read. |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Remove overridden assignment</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/overridden-assignment-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/overridden-assignment-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="embedded-if"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=565912 --> |
| <td class="title"><a href="#embedded-if">Raise embedded if into parent if</a></td> |
| <td class="content"> |
| A new clean up has been added that merges inner <code>if</code> statement into the parent <code>if</code> statement. |
| <p> |
| The cleanup checks that there is no <code>else</code> statement. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Raise embedded if into parent if</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/embedded-if-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/embedded-if-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="redundant-return"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567286 --> |
| <td class="title"><a href="#redundant-return">Redundant return</a></td> |
| <td class="content"> |
| A new clean up has been added that removes useless lone <code>return</code> at the end of a method or lambda. |
| <p> |
| The cleanup checks that there is no value on the <code>return</code> statement. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Remove useless return</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/redundant-return-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/redundant-return-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="redundant-continue"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567411 --> |
| <td class="title"><a href="#redundant-continue">Redundant continue</a></td> |
| <td class="content"> |
| A new clean up has been added that removes useless lone <code>continue</code> at the end of a loop. |
| <p> |
| A <code>continue</code> statement at the end of a loop is removed. |
| A <code>continue</code> statement at the end of a control statement is removed if the control statement is at the end of a loop. |
| A <code>continue</code> statement is kept if it has a label. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Remove useless continue</b> check box on the <b>Unnecessary Code</b> tab. |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/redundant-continue-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/redundant-continue-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="try-with-resource"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568088 --> |
| <td class="title"><a href="#try-with-resource">Use try-with-resource</a></td> |
| <td class="content"> |
| A new clean up has been added that changes code to make use of Java 7 try-with-resources feature. In particular, it removes now useless <code>finally</code> clauses. |
| <p> |
| It may move an inner closeable assignment as a resource. It handles <code>finally</code> with a simple <code>close()</code> invocation, a null-check and remaining statements below. |
| </p> |
| <p> |
| It is only enabled from Java 7 and it also handles the Java 9 syntax. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Use try-with-resource</b> check box on the <b>Unnecessary Code</b> tab (or the <b>Java Feature</b> tab starting from Eclipse 2021-03). |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/try-with-resource-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/try-with-resource-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="break-loop"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568050 --> |
| <td class="title"><a href="#break-loop">Exit loop earlier</a></td> |
| <td class="content"> |
| A new clean up has been added that adds a <code>break</code> to avoid passive <code>for</code> loop iterations. |
| <p> |
| The inner assignments must not do other different assignments after (assign other values or assign into other variables). |
| </p> |
| <p> |
| There must be no side effects after the first assignments. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Exit loop earlier</b> check box on the <b>Optimization</b> tab (the <b>Performance</b> tab in Eclipse 2021-09). |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/break-loop-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/break-loop-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="stringbuilder"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568472 --> |
| <td class="title"><a href="#stringbuilder">Use StringBuilder</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces <code>String</code> concatenation by <code>StringBuilder</code> when possible. |
| <p> |
| It uses <code>StringBuffer</code> for Java 1.4-. |
| </p> |
| <p> |
| It only replaces strings on several statements and the concatenation should have more than two pieces. |
| </p> |
| <p> |
| The variable should be only concatenated and it should retrieve the string once. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Replace String concatenation by StringBuilder</b> check box on the <b>Optimization</b> tab (the <b>Performance</b> tab in Eclipse 2021-09). |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/stringbuilder-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/stringbuilder-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="primitive-serialization"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568327 --> |
| <td class="title"><a href="#primitive-serialization">Primitive serialization</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces a primitive boxing to serialize by a call to the static <code>toString()</code> method. |
| <p> |
| It works for all the primitive types: <code>boolean</code>, <code>char</code>, <code>byte</code>, <code>short</code>, <code>int</code>, <code>long</code>, <code>float</code> and <code>double</code>. |
| </p> |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Primitive serialization</b> check box on the <b>Optimization</b> tab (the <b>Performance</b> tab in Eclipse 2021-09). |
| </p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/primitive-serialization-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/primitive-serialization-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="boolean-literal"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567560 --> |
| <td class="title"><a href="#boolean-literal">Prefer boolean literal</a></td> |
| <td class="content"> |
| A new clean up has been added that replaces <code>Boolean.TRUE</code>/<code>Boolean.FALSE</code> by <code>true</code>/<code>false</code> when used as primitive. |
| <p> |
| To apply the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog, select <b>Prefer boolean literals</b> check box on the <b>Optimization</b> tab (the <b>Performance</b> tab in Eclipse 2021-09). |
| </p> |
| <p><img src="images/boolean-literal-preferences.png" alt="Preferences" width="800"/></p> |
| <p> |
| For the given code: |
| </p> |
| <p><img src="images/boolean-literal-before.png" alt="Before"/></p> |
| <p> |
| One gets: |
| </p> |
| <p><img src="images/boolean-literal-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="diamond-operator"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567970 --> |
| <td class="title"><a href="#diamond-operator">Diamond operator <> (Remove redundant type arguments)</a></td> |
| <td class="content"> |
| The clean up <b>Remove redundant type arguments</b> has been renamed <b>Use diamond operator</b> and is still available in the <b>Unnecessary Code</b> tab in Eclipse 2020-12. |
| <p> |
| The clean up will be moved to the future <b>Java Feature</b> tab in Eclipse 2021-03. |
| </p> |
| </td> |
| </tr> |
| |
| <!-- ******************* End of Java Editor ************************************* --> |
| |
| <!-- ******************* Java Views and Dialogs ************************************* --> |
| <tr> |
| <td id="JavaViewsAndDialogs" class="section" colspan="2"> |
| <h2>Java Views and Dialogs</h2> |
| </td> |
| </tr> |
| |
| <tr id="search-permitted-types"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=564624 --> |
| <td class="title"><a href="#search-permitted-types">Fine-grained search for permitted types</a></td> |
| <td class="content"> |
| You can perform a fine-grained search for permitted type declarations in the <b>Search dialog (Ctrl+H) > Java Search > Limit To > Match Locations</b> with the new option: |
| <p> |
| <img src="images/search_permitted_type.png" alt="" /> |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="package-explorer-lib-sortedbydefault"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=568877 --> |
| <td class="title"><a href="#package-explorer-lib-sortedbydefault">Sort library entries alphabetically in Package Explorer enabled by default</a></td> |
| <td class="content"> |
| The <b>Preferences > Java > Appearance > [x] Sort library entries alphabetically in Package Explorer</b> is now enabled by default. |
| This makes it easier for you to see if a library is available or not. |
| <p> |
| If you want to see the order in which the libraries are added to the classpath, e.g. to understand classpath loading issues, you can disable the preference. |
| </p> |
| </td> |
| </tr> |
| |
| <!-- ******************* End of Java Views and Dialogs ************************************* --> |
| |
| <!-- ******************* Java Compiler ************************************* --> |
| <!--<tr> |
| <td id="JavaCompiler" class="section" colspan="2"> |
| <h2>Java Compiler</h2> |
| </td> |
| </tr>--> |
| <!-- ******************* End of Java Compiler ************************************* --> |
| |
| <!-- ******************* Java Formatter ************************************* --> |
| <tr> |
| <td id="JavaFormatter" class="section" colspan="2"> |
| <h2>Java Formatter </h2> |
| </td> |
| </tr> |
| |
| <tr id="formatter-wrap-annotations"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=567160 --> |
| <td class="title"><a href="#formatter-wrap-annotations">Annotations wrapping</a></td> |
| <td class="content"> |
| The formatter now allows more control over <b>how multiple annotations on a single element should be divided into lines</b>. |
| Previously, they could either all be placed in a single line along with the annotated element, or each in a separate line. |
| The settings that controlled this behavior (in the <b>New Lines > After annotations</b> section) now only control a line break between the last annotation and the annotated element. |
| Line breaks between annotations are controlled by a new group of settings in the <b>Line Wrapping > Wrapping Settings > Annotations</b> section. |
| <p>Just like with standard wrapping settings, they can be set to keep everything in a single line (<b>Do not wrap</b>), each annotation in a separate line (<b>Wrap all elements</b>), or only break lines that exceed the width limit (<b>Wrap where necessary</b>). |
| The last option along with the <b>Never join already wrapped lines</b> setting effectively means manual control over each case. |
| The annotation wrapping settings differ from other wrapping settings in that the indentation control is not available.</p> |
| <p>The formatter configuration sections can be found in the <b>Profile Editor</b> (<b>Preferences > Java > Code Style > Formatter > Edit...</b>).</p> |
| <p><img src="images/formatter-wrap-annotations.png" alt=""/></p> |
| </td> |
| </tr> |
| <!-- ******************* End of Java Formatter ************************************* --> |
| |
| <!-- *********************** Debug ******************************** --> |
| <tr> |
| <td id="Debug" class="section" colspan="2"> |
| <h2>Debug</h2> |
| </td> |
| </tr> |
| <tr id="launch-with-argfile"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=565902 --> |
| <td class="title"><a href="#launch-with-argfile">Support for @argfiles when launching</a></td> |
| <td class="content"> |
| A new check box was added to the <b>Arguments</b> tab for Java based launch configurations (Java Application, JUnit, and others) for writing arguments into an @argfile. |
| This is disabled below Java 9 and can be enabled for Java programs launched with Java 9 and above. |
| <p> |
| <img src="images/launch-with-argfile.png" alt="screenshot showing new checkbox" /> |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="logicalstructure-gc"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=537399 --> |
| <td class="title"><a href="#logicalstructure-gc">Stabilized logical structures in Variables view with active GC</a></td> |
| <td class="content"> |
| The <b>Debug</b> view no longer breaks when logical structures are shown while the application's garbage collector is active |
| (<code>com.sun.jdi.ObjectCollectedException</code> occurred while retrieving value). |
| </td> |
| </tr> |
| <!--************************ End of Debug ******************************** --> |
| |
| <!-- *********************** JDT Developers ******************************** --> |
| |
| <!-- *********************** End of JDT Developers ******************************** --> |
| </tbody> |
| </table> |
| <!-- ****************** END OF N&N TABLE ****************** --> |
| |
| <script type="text/javascript" src="scripts.js"></script> |
| <p style="text-align:center"> |
| <a href="platform.php">Previous</a> <a style="margin:1em" href=".">Up</a> <a href="platform_isv.php">Next</a> |
| </p> |
| </body> |
| </html> |