-
Notifications
You must be signed in to change notification settings - Fork 67
/
jdt_whatsnew.html
886 lines (835 loc) · 41.6 KB
/
jdt_whatsnew.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
<!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.18 (JDT)</title>
</head>
<body>
<h2>What's New in Eclipse 4.18 (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.18 release of Eclipse.
They are grouped into:</p>
<ul> <!-- NOTE: Sync ../topics_WhatsNew.xml with this! -->
<!--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>
<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 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">JUnit 5.7</td>
<td class="content">
<a href="https://junit.org/junit5/docs/current/release-notes/index.html#release-notes-5.7.0/" target="_blank">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">Insert best guessed parameters in Java editor</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">Quick assist to create new implementation</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">Quick fixes on permitted types</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.
</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" target="_blank">"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.
</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" target="_blank">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.
</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.
</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.
</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.
</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.
</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.
</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.
</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>
<!-- ******************* 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">Fine-grained search for permitted types</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">Sort library entries alphabetically in Package Explorer enabled by default</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">Support for @argfiles when launching</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">Stabilized logical structures in Variables view with active GC</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 ****************** -->
</body>
</html>