diff options
| author | Fabrice Tiercelin | 2020-11-19 17:36:53 +0000 |
|---|---|---|
| committer | Fabrice Tiercelin | 2020-11-19 17:36:53 +0000 |
| commit | 0db30a015a92d9d6b742193f57590a2b92cdfe4d (patch) | |
| tree | 9830643a21c795a9aeb97a5ff50c322d5b37d3d2 | |
| parent | f7377d6c1350b735d5ffe0cde2fce8dd8de9f694 (diff) | |
| download | news-0db30a015a92d9d6b742193f57590a2b92cdfe4d.tar.gz news-0db30a015a92d9d6b742193f57590a2b92cdfe4d.tar.xz news-0db30a015a92d9d6b742193f57590a2b92cdfe4d.zip | |
Bug 568088 - [AutoRefactor immigration #37/141] [cleanup & saveaction]
try-with-resource
Change-Id: I43136b66d5a76d3d8644a7c661e0f5caa310126b
Signed-off-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Depends-On: If847e94774241882996aac7f5914018507ea20c8
| -rw-r--r-- | 4.18/images/try-with-resource-after.png | bin | 0 -> 15540 bytes | |||
| -rw-r--r-- | 4.18/images/try-with-resource-before.png | bin | 0 -> 14914 bytes | |||
| -rw-r--r-- | 4.18/jdt.html | 24 |
3 files changed, 24 insertions, 0 deletions
diff --git a/4.18/images/try-with-resource-after.png b/4.18/images/try-with-resource-after.png Binary files differnew file mode 100644 index 00000000..8bf240bd --- /dev/null +++ b/4.18/images/try-with-resource-after.png diff --git a/4.18/images/try-with-resource-before.png b/4.18/images/try-with-resource-before.png Binary files differnew file mode 100644 index 00000000..1e6dd2ce --- /dev/null +++ b/4.18/images/try-with-resource-before.png diff --git a/4.18/jdt.html b/4.18/jdt.html index d13e20d2..6c2fcda5 100644 --- a/4.18/jdt.html +++ b/4.18/jdt.html @@ -558,6 +558,30 @@ ul {padding-left: 13px;} </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. + </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"> |
