| <!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 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="../book.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>What's New in Eclipse 4.15 (JDT)</title> |
| </head> |
| |
| <body> |
| <h2>What's New in Eclipse 4.15 (JDT)</h2> |
| <p>Here are descriptions of some of the more interesting or significant changes made to the Java development tools (JDT) |
| for the 4.15 release of Eclipse. |
| They are grouped into:</p> |
| <ul> |
| <!-- <li><a href="#Java14">Java™ 14 Support</a></li> --> |
| <li><a href="#JavaEditor">Java Editor</a></li> |
| <li><a href="#JavaCompiler">Java Compiler</a></li> |
| <li><a href="#JavaFormatter">Java Formatter</a></li> |
| <li><a href="#Debug">Java Debugger</a></li> |
| <li><a href="#JDTDev">JDT Developers</a></li> |
| </ul> |
| |
| <p>See also the <b><a href="../../org.eclipse.platform.doc.user/whatsNew/platform_whatsnew.html">Eclipse Platform What's New</a></b> |
| document for changes in the Platform.</p> |
| <p>We also recommend to read the <a href="../tips/jdt_tips.html">Tips and Tricks</a>.</p> |
| <br/> |
| |
| <!-- ****************** START OF N&N TABLE****************** --> |
| <table class="news"> |
| <colgroup> |
| <col class="title" /> |
| <col /> |
| </colgroup> |
| <tbody> |
| |
| <!-- ******************* Java 14 Support ************************************* |
| <tr> |
| <td id="Java14" class="section" colspan="2"> |
| <h2>Java™ 14 Support </h2> |
| </td> |
| </tr> |
| ******************* End of Java 14 Support ************************************* --> |
| |
| <!-- ******************* Java Editor ************************************* --> |
| <tr> |
| <td id="JavaEditor" class="section" colspan="2"> |
| <h2>Java Editor </h2> |
| </td> |
| </tr> |
| |
| <tr id="subword-code-completion"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=559496 --> |
| <td class="title">Subword code completion</td> |
| <td class="content"> |
| Content Assist now supports subword patterns, similar to Eclipse Code Recommenders and other IDEs. |
| For example, completing on <code>addmouselistener</code> proposes results like |
| <code><b>addMouse</b>Move<b>Listener</b></code> and <code><b>addMouse</b>Wheel<b>Listener</b></code>. |
| <p> |
| <img src="images/subword-code-completion.png" alt=""/> |
| </p> |
| <p> |
| This feature can be enabled using the <b>Show subword matches</b> option on the |
| <b>Java > Editor > Content Assist</b> preference page. |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="subtype-code-completion"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=277691 --> |
| <td class="title">Subtype code completion</td> |
| <td class="content"> |
| Content Assist will prioritize displaying constructor completions whose |
| declaring type inherits from the expected return type within the |
| completion context. |
| <p>For example, completing on :</p> |
| |
| <p><code>Queue<String> queue = new L</code></p> |
| |
| <p> |
| prioritizes constructors for <code><b>LinkedBlockingQueue</b></code>, <code><b>LinkedBlockingDeQueue</b></code> and <code><b>LinkedList</b></code>. |
| </p> |
| <p> |
| <img src="images/subtype-code-completion.png" alt=""/> |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="non-blocking-completion"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=531061 --> |
| <td class="title">Option for non-blocking Java completion</td> |
| <td class="content"> |
| Code completion in the Java editor can now be run in a separate non-UI thread to prevent |
| UI freezes in case of long computations. To enable this non-blocking computation, go to <b>Preferences > |
| Java > Editor > Content Assist > Advanced</b> and check <b>Do not block UI Thread while computing completion |
| proposals</b> preference. This option is currently disabled by default. |
| <p>Non-blocking completion is useful when completion proposals are long to compute, as it allows you |
| to type or use other parts of the IDE in the meantime.</p> |
| <p>Some completion participants may prevent this option from being effective (typically if the Java completion extension |
| doesn't declare <code>requiresUIThread="false"</code>), so the UI thread may still be used even if this option is set.<br/> |
| The open Java file editors need to be closed and reopened for this option to be effective.</p> |
| </td> |
| </tr> |
| |
| <tr id="quickfix-wrap-optional"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=473276 --> |
| <td class="title">Quick fix to wrap Optional statements</td> |
| <td class="content"> |
| A quick fix has been added to wrap an <code>Optional</code> statement. |
| <p> |
| The options for a primitive statement are: <code>Optional.empty()</code> and <code>Optional.of()</code>. Type statements |
| also have <code>Optional.ofNullable()</code>. |
| </p> |
| <p>Example for type objects:</p> |
| <p><img src="images/wrapOptional1.png" alt=""/></p> |
| Selecting <b>Wrap with nullable Optional</b> for type object results in: |
| <p><img src="images/wrapOptional4.png" alt=""/></p> |
| Example for primitive: |
| <p><img src="images/wrapOptional2.png" alt=""/></p> |
| Selecting <b>Wrap with Optional</b> for primitive results in: |
| <p><img src="images/wrapOptional3.png" alt=""/></p> |
| </td> |
| </tr> |
| |
| <tr id="improve-lambda"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=550394 --> |
| <td class="title">Simplify functional interface instances</td> |
| <td class="content"> |
| A new clean up has been added that simplifies the lambda expression and the method reference syntax and is enabled only for Java 8 and higher. |
| <p> |
| The clean up removes parenthesis for a single untyped parameter, return statement for a single expression and |
| brackets for a single statement. It replaces a lambda expression by a creation or a method reference when possible. |
| </p> |
| <p> |
| To select the clean up, invoke <b>Source > Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog select <b>Simplify lambda |
| expression and method reference syntax</b> on the <b>Code Style</b> tab. |
| </p> |
| <p><img src="images/lambda-expression-enhancements.png" alt=""/></p> |
| For the given code: |
| <p><img src="images/lambda-expression-enhancements-before.png" alt=""/></p> |
| You get this after the clean up: |
| <p><img src="images/lambda-expression-enhancements-after.png" alt=""/></p> |
| </td> |
| </tr> |
| |
| <tr id="map-method"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=551614 --> |
| <td class="title">Directly use Map method</td> |
| <td class="content"> |
| Some map manipulations are unnecessarily verbose. The new cleanup option <b>Operate on Maps directly</b> calls methods on a map instead of calling |
| the same methods on the key set or the values. |
| <p> |
| Beware! If you create <code>Map</code> implementations that don't follow the Map specification, this cleanup may break the behavior |
| (a <code>size()</code> method that changes the values, an iterator that destroys the items...). |
| </p> |
| <p><img src="images/map-method-preferences.png" alt="Preferences"/></p> |
| For the given code: |
| <p><img src="images/map-method-before.png" alt="Before"/></p> |
| You get this after the clean up: |
| <p><img src="images/map-method-after.png" alt="After"/></p> |
| </td> |
| </tr> |
| |
| <tr id="uppercase-literal-suffix"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=552456 --> |
| <td class="title">Uppercase for long literal suffix</td> |
| <td class="content"> |
| A new cleanup option <b>Use uppercase for long literal suffix</b> has been added. It will rewrite long literals like <code>101l</code> with an uppercase L like <code>101L</code> to avoid ambiguity. |
| <p><img src="images/uppercase-literal-suffix.png" alt=""/></p> |
| </td> |
| </tr> |
| |
| <tr id="surround-with-try-with-resources"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=553113 --> |
| <td class="title">Surround with "try-with-resources" block</td> |
| <td class="content"> |
| Corresponding to the quick fix which will surround a selection with a "try-with-resources" block, a new |
| action has been added to the <b>Surround With</b> menu. |
| <p>For example, selecting the lines as shown:</p> |
| <p><img src="images/surroundwithresources1.png" alt=""/></p> |
| <p>and right-clicking and selecting <b>Surround With -> Try-with-resources Block</b></p> |
| <p><img src="images/surroundwithresources.png" alt=""/></p> |
| <p>results in:</p> |
| <p><img src="images/surroundwithresources2.png" alt=""/></p> |
| </td> |
| </tr> |
| |
| <tr id="module-info-javadoc-quickfix"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=553111 --> |
| <td class="title">Quick fixes for module-info Javadoc</td> |
| <td class="content"> |
| Quick fixes have been added to fix the missing and duplicate <code>@provides</code> and <code>@uses</code> Javadoc tags in a <code>module-info</code> file. |
| <p><img src="images/modulequickfix.png" alt=""/></p> |
| </td> |
| </tr> |
| |
| <tr id="import-completion"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=15589 --> |
| <td class="title">No more spurious semicolon from import completion</td> |
| <td class="content"> |
| Almost 18 years ago, it was reported that completion for imports adds an unnecessary semicolon if one |
| already exists (like when changing an existing import). Now this extra semicolon is no longer inserted. |
| </td> |
| </tr> |
| |
| <!-- ******************* End of Java Editor ************************************* --> |
| |
| <!-- ******************* Java Compiler ************************************* --> |
| <tr> |
| <td id="JavaCompiler" class="section" colspan="2"> |
| <h2>Java Compiler</h2> |
| </td> |
| </tr> |
| |
| <tr id="null-legacy-interface"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=482242 --> |
| <td class="title">Warn when legacy code can taint null-checked values</td> |
| <td class="content"> |
| When using null-annotations for advanced null analysis, it is inherently tricky to combine your |
| code with "legacy" code that has no null annotations and has not been blessed by such analysis. |
| <p>Previously, Eclipse would only warn you when you <em>obtain</em> a dubious value <em>from</em> a legacy API, |
| but it would keep silent in the opposite case: <em>passing</em> a value of an annotated type |
| <em>into</em> legacy API. Still in specific situations this can cause a |
| <code>NullPointerException</code> to be thrown in your null-checked code: |
| </p> |
| <p> |
| <img src="images/null-into-nonnull-list.png" alt=""/> |
| </p> |
| <p> |
| The console shows an exception thrown from within your checked main method (see the |
| class-level <code>@NonNullByDefault</code>). |
| It also shows the new warning, which Eclipse raises to alert you of this danger. |
| </p> |
| <p> |
| <em>Hint:</em> The shown code assumes the list <code>names</code> to have type <code>List<@NonNull String></code>, |
| but the legacy method <code>Legacy.printNames()</code> succeeds to taint this list |
| by inserting a <code>null</code> element. |
| This goes unnoticed because that method views the list has having type <code>List<String></code>, |
| with no nullness constraint on the type argument. |
| </p> |
| <p> |
| By default this problem is raised at level <code>info</code>, |
| but the severity can be configured in the compiler settings: |
| </p> |
| <p> |
| <img src="images/configure-null-vs-legacy-problem.png" alt=""/> |
| </p> |
| </td> |
| </tr> |
| |
| <tr id="resource-leak-analysis"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=463320 --> |
| <td class="title">Improved Resource leak analysis</td> |
| <td class="content"> |
| Resource leak analysis has been improved in several ways. |
| <p> |
| Most importantly, the analysis now consistently considers resources (=values of type <code>AutoCloseable</code>) |
| which are acquired using a method call, where previously under some circumstances resource allocation |
| got unnoticed if it was wrapped in a factory method, like in the following example: |
| </p> |
| <pre> |
| makePrintWriter("/tmp/log.txt").printf("%d", 42); |
| // a PrintWriter is never closed! |
| </pre> |
| <p> |
| Second, resource leak analysis now leverages knowledge about well-known resource classes that support fluent programming, |
| i.e., instance methods which return <code>this</code> to enable chains of method calls. Where a naive analysis |
| could consider the method result as a new resource coming into scope, special knowledge about these classes |
| informs the analysis that it is one and the same resource. This concerns the following system classes: |
| </p> |
| <dl> |
| <dt>from java.io</dt> |
| <dd>CharArrayWriter, Console, PrintStream, PrintWriter, StringWriter, Writer</dd> |
| <dt>from java.nio.channels</dt> |
| <dd>AsynchronousFileChannel, AsynchronousServerSocketChannel, FileChannel, NetworkChannel, SeekableByteChannel, |
| SelectableChannel, Selector, ServerSocketChannel</dd> |
| <dt>from java.util</dt> |
| <dd>Formatter</dd> |
| </dl> |
| <p> |
| The following example is now understood to be safe, because analysis understands that the resource |
| returned by <code>append()</code> is the same as the initial <code>pw</code>: |
| </p> |
| <pre> |
| PrintWriter pw = new PrintWriter("/tmp/log.txt"); |
| pw.printf("%d", 42).append(" is the answer").close(); |
| </pre> |
| <p> |
| Generally, resource leak analysis was made more precise regarding several specific situations. |
| </p> |
| </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-application"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=543363 --> |
| <td class="title">Java formatter application requires a workspace</td> |
| <td class="content"> |
| The Java formatter application will provide a sensible error message if a workspace |
| is required but not provided (<code>-data</code> command line option). This also enables |
| the <code>-help</code> option to be run on the formatter without a workspace specified. |
| <p>A new bundle services the <code>org.eclipse.jdt.core.JavaCodeFormatter</code> application. |
| This new bundle is part of the JDT feature. Users who are not using the JDT feature |
| to define their set of bundles will need to add <code>org.eclipse.jdt.core.formatterapp</code> |
| to their set of bundles.</p> |
| </td> |
| </tr> |
| |
| <!-- ******************* End of Java Formatter ************************************* --> |
| |
| <!-- *********************** Debug ******************************** --> |
| <tr> |
| <td id="Debug" class="section" colspan="2"> |
| <h2>Debug</h2> |
| </td> |
| </tr> |
| |
| <tr id="functional-expressions-in-debug"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=448473 --> |
| <td class="title">Functional debug expressions</td> |
| <td class="content"> |
| Lambda expressions and method references are now supported in debug expressions, such as in the <b>Expressions view</b> |
| and in breakpoint condition expressions. |
| <p><img src="images/debug-functional-expressions.png" alt="Debug Expression containing a lambda"/></p> |
| <p>Some limitations apply: The feature should be considered a MVP (Minimally Viable Product). |
| It is not yet possible to reference non-public fields and methods of the enclosing class. |
| The evaluation may not work in system classes and some generic contexts. |
| </p> |
| </td> |
| </tr> |
| |
| <!--************************ End of Debug ******************************** --> |
| |
| <!-- *********************** JDT Developers ******************************** --> |
| <tr> |
| <td id="JDTDev" class="section" colspan="2"> |
| <h2>JDT Developers</h2> |
| </td> |
| </tr> |
| |
| <tr id="new-formatterapp-bundle"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=543363 --> |
| <td class="title">New bundle <code>org.eclipse.jdt.core.formatterapp</code></td> |
| <td class="content"> |
| The entry point of the <code>org.eclipse.jdt.core.JavaCodeFormatter</code> application has been |
| moved to a new bundle, <code>org.eclipse.jdt.core.formatterapp</code>. |
| </td> |
| </tr> |
| <!-- *********************** End of JDT Developers ******************************** --> |
| </tbody> |
| </table> |
| <!-- ****************** END OF N&N TABLE ****************** --> |
| |
| </body> |
| </html> |