Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8a0b1d2e290402f465db24d0c649a02acfe66dcd (plain) (blame)
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
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
/*******************************************************************************
 * Copyright (c) 2005, 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Stephan Herrmann <stephan@cs.tu-berlin.de> - Contribution for bug 185682 - Increment/decrement operators mark local variables as read
 *******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;

import java.util.Map;

import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;

import junit.framework.Test;

public class AssignmentTest extends AbstractRegressionTest {

public AssignmentTest(String name) {
	super(name);
}
protected Map getCompilerOptions() {
	Map options = super.getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE);
	options.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR);
	options.put(CompilerOptions.OPTION_ReportPotentialNullReference, CompilerOptions.ERROR);
	options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.ERROR);
	options.put(CompilerOptions.OPTION_ReportNoEffectAssignment, CompilerOptions.ERROR);
	return options;
}
// Static initializer to specify tests subset using TESTS_* static variables
// All specified tests which does not belong to the class are skipped...
static {
//	TESTS_NAMES = new String[] { "test000" };
//	TESTS_NUMBERS = new int[] { 69 };
//	TESTS_RANGE = new int[] { 11, -1 };
}
public static Test suite() {
	Test suite = buildAllCompliancesTestSuite(testClass());
	return suite;
}
/*
 * no effect assignment bug
 * http://bugs.eclipse.org/bugs/show_bug.cgi?id=27235
 */
public void test001() {
	this.runConformTest(		new String[] {
			"X.java",
			"public class X {	\n" +
			"    int i;	\n" +
			"    X(int j) {	\n" +
			"    	i = j;	\n" +
			"    }	\n" +
			"    X() {	\n" +
			"    }	\n" +
			"    class B extends X {	\n" +
			"        B() {	\n" +
			"            this.i = X.this.i;	\n" +
			"        }	\n" +
			"    }	\n" +
			"    public static void main(String[] args) {	\n" +
			"        X a = new X(3);	\n" +
			"        System.out.print(a.i + \" \");	\n" +
			"        System.out.print(a.new B().i);	\n" +
			"	}	\n" +
			"}	\n",
		},
		"3 3");
}

public void test002() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	int a;	\n" +
			"	X next;	\n" +
			"	public void foo(int arg){	\n" +
			"	\n" +
			"		zork = zork;	\n" +
			"		arg = zork;	\n" +
			"	\n" +
			"		arg = arg;  // noop	\n" +
			"		a = a;  // noop	\n" +
			"		this.next = this.next; // noop	\n" +
			"		this.next = next; // noop	\n" +
			"	\n" +
			"		next.a = next.a; // could raise NPE	\n" +
			"		this.next.next.a = next.next.a; // could raise NPE	\n" +
			"		a = next.a; // could raise NPE	\n" +
			"		this. a = next.a; 	\n" +
			"	}	\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 6)\n" +
		"	zork = zork;	\n" +
		"	^^^^\n" +
		"zork cannot be resolved to a variable\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 6)\n" +
		"	zork = zork;	\n" +
		"	       ^^^^\n" +
		"zork cannot be resolved to a variable\n" +
		"----------\n" +
		"3. ERROR in X.java (at line 7)\n" +
		"	arg = zork;	\n" +
		"	      ^^^^\n" +
		"zork cannot be resolved to a variable\n" +
		"----------\n" +
		"4. ERROR in X.java (at line 9)\n" +
		"	arg = arg;  // noop	\n" +
		"	^^^^^^^^^\n" +
		"The assignment to variable arg has no effect\n" +
		"----------\n" +
		"5. ERROR in X.java (at line 10)\n" +
		"	a = a;  // noop	\n" +
		"	^^^^^\n" +
		"The assignment to variable a has no effect\n" +
		"----------\n" +
		"6. ERROR in X.java (at line 11)\n" +
		"	this.next = this.next; // noop	\n" +
		"	^^^^^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable next has no effect\n" +
		"----------\n" +
		"7. ERROR in X.java (at line 12)\n" +
		"	this.next = next; // noop	\n" +
		"	^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable next has no effect\n" +
		"----------\n");
}
public void test003() {
	this.runConformTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	int portNumber;\n" +
			"	public static void main(String[] args) {\n" +
			"		X x = new X();\n" +
			"		x.portNumber = Integer.parseInt(\"12\");\n" +
			"		x.run();\n" +
			"	}\n" +
			"	private void run() {\n" +
			"		System.out.println(portNumber);\n" +
			"	}\n" +
			"}", // =================

		},
		"12");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=151787
public void test004() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"    // correctly passes compilation\n" +
			"    static class Test1 {\n" +
			"        private final Object o;\n" +
			"        \n" +
			"        Test1() {\n" +
			"            o = new Object();\n" +
			"        }\n" +
			"    }\n" +
			"    \n" +
			"    // correctly passes compilation\n" +
			"    static class Test2 {\n" +
			"        private final Object o;\n" +
			"        \n" +
			"        Test2() {\n" +
			"            this.o = new Object();\n" +
			"        }\n" +
			"    }\n" +
			"    \n" +
			"    // correctly fails compilation\n" +
			"    static class Test3 {\n" +
			"        private final Object o;\n" +
			"        \n" +
			"        Test3() {\n" +
			"            System.out.println(o); // illegal; o is not definitely assigned\n" +
			"            o = new Object();\n" +
			"        }\n" +
			"    }\n" +
			"    \n" +
			"    // correctly passes compilation\n" +
			"    static class Test4 {\n" +
			"        private final Object o;\n" +
			"        \n" +
			"        Test4() {\n" +
			"            System.out.println(this.o); // legal\n" +
			"            o = new Object();\n" +
			"        }\n" +
			"    }\n" +
			"    \n" +
			"    // incorrectly passes compilation\n" +
			"    static class Test5 {\n" +
			"        private final Object o;\n" +
			"        \n" +
			"        Test5() {\n" +
			"            Test5 other = this;\n" +
			"            other.o = new Object(); // illegal!  other.o is not assignable\n" +
			"        } // error: this.o is not definitely assigned\n" +
			"    }\n" +
			"    \n" +
			"    // flags wrong statement as error\n" +
			"    static class Test6 {\n" +
			"        private final Object o;\n" +
			"        static Test6 initing;\n" +
			"        \n" +
			"       Test6() {\n" +
			"           initing = this;\n" +
			"           System.out.println(\"greetings\");\n" +
			"           Test6 other = initing;\n" +
			"           other.o = new Object(); // illegal!  other.o is not assignable\n" +
			"           o = new Object(); // legal\n" +
			"       }\n" +
			"    }\n" +
			"}\n", // =================
		},
		"----------\n" +
		"1. WARNING in X.java (at line 4)\n" +
		"	private final Object o;\n" +
		"	                     ^\n" +
		"The value of the field X.Test1.o is not used\n" +
		"----------\n" +
		"2. WARNING in X.java (at line 13)\n" +
		"	private final Object o;\n" +
		"	                     ^\n" +
		"The value of the field X.Test2.o is not used\n" +
		"----------\n" +
		"3. ERROR in X.java (at line 25)\n" +
		"	System.out.println(o); // illegal; o is not definitely assigned\n" +
		"	                   ^\n" +
		"The blank final field o may not have been initialized\n" +
		"----------\n" +
		"4. WARNING in X.java (at line 42)\n" +
		"	private final Object o;\n" +
		"	                     ^\n" +
		"The value of the field X.Test5.o is not used\n" +
		"----------\n" +
		"5. ERROR in X.java (at line 44)\n" +
		"	Test5() {\n" +
		"	^^^^^^^\n" +
		"The blank final field o may not have been initialized\n" +
		"----------\n" +
		"6. ERROR in X.java (at line 46)\n" +
		"	other.o = new Object(); // illegal!  other.o is not assignable\n" +
		"	      ^\n" +
		"The final field X.Test5.o cannot be assigned\n" +
		"----------\n" +
		"7. WARNING in X.java (at line 52)\n" +
		"	private final Object o;\n" +
		"	                     ^\n" +
		"The value of the field X.Test6.o is not used\n" +
		"----------\n" +
		"8. ERROR in X.java (at line 59)\n" +
		"	other.o = new Object(); // illegal!  other.o is not assignable\n" +
		"	      ^\n" +
		"The final field X.Test6.o cannot be assigned\n" +
		"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=190391
public void test005() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	final int contents;\n" +
			"	\n" +
			"	X() {\n" +
			"		contents = 3;\n" +
			"	}\n" +
			"	X(X other) {\n" +
			"		other.contents = 5;\n" +
			"	}\n" +
			"	\n" +
			"	public static void main(String[] args) {\n" +
			"		X one = new X();\n" +
			"		System.out.println(\"one.contents: \" + one.contents);\n" +
			"		X two = new X(one);\n" +
			"		System.out.println(\"one.contents: \" + one.contents);\n" +
			"		System.out.println(\"two.contents: \" + two.contents);\n" +
			"	}\n" +
			"}\n", // =================
		},
		"----------\n" +
		"1. ERROR in X.java (at line 7)\n" +
		"	X(X other) {\n" +
		"	^^^^^^^^^^\n" +
		"The blank final field contents may not have been initialized\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 8)\n" +
		"	other.contents = 5;\n" +
		"	      ^^^^^^^^\n" +
		"The final field X.contents cannot be assigned\n" +
		"----------\n");
}
// final multiple assignment
public void test020() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	void foo() {\n" +
			"		final int v;\n" +
			"		for (int i = 0; i < 10; i++) {\n" +
			"			v = i;\n" +
			"		}\n" +
			"		v = 0;\n" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 5)\n" +
		"	v = i;\n" +
		"	^\n" +
		"The final local variable v may already have been assigned\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 7)\n" +
		"	v = 0;\n" +
		"	^\n" +
		"The final local variable v may already have been assigned\n" +
		"----------\n");
}

// null part has been repeated into NullReferenceTest#test1033
public void test033() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	\n" +
			"	void foo() {\n" +
			"		String a,b;\n" +
			"		do{\n" +
			"		   a=\"Hello \";\n" +
			"		}while(a!=null);\n" +
			"				\n" +
			"		if(a!=null)\n" +
			"		{\n" +
			"		   b=\"World!\";\n" +
			"		}\n" +
			"		System.out.println(a+b);\n" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 7)\n" +
		"	}while(a!=null);\n" +
		"	       ^\n" +
		"Redundant null check: The variable a cannot be null at this location\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 9)\n" +
		"	if(a!=null)\n" +
		"	   ^\n" +
		"Null comparison always yields false: The variable a can only be null at this location\n" +
		"----------\n" +
		"3. ERROR in X.java (at line 13)\n" +
		"	System.out.println(a+b);\n" +
		"	                     ^\n" +
		"The local variable b may not have been initialized\n" +
		"----------\n");
}

//https://bugs.eclipse.org/bugs/show_bug.cgi?id=84215
//TODO (philippe) should move to InitializationTest suite
public void test034() {
	this.runConformTest(
		new String[] {
			"X.java",
			"public final class X \n" +
			"{\n" +
			"	public static String vdg;\n" +
			"	public static final String aa = null;\n" +
			"	public static final int a = 14;\n" +
			"	public static final int b = 3;\n" +
			"	private static final int c = 12;\n" +
			"	private static final int d = 2; \n" +
			"	private static final int e = 3; \n" +
			"	private static final int f = 34; \n" +
			"	private static final int g = 35; \n" +
			"	private static final int h = 36; \n" +
			"	private static final int j = 4;\n" +
			"	private static final int k = 1;\n" +
			"	public static final int aba = 1;\n" +
			"	public static final int as = 11;\n" +
			"	public static final int ad = 12;\n" +
			"	public static final int af = 13;\n" +
			"	public static final int ag = 2;\n" +
			"	public static final int ah = 21;\n" +
			"	public static final int aj = 22;\n" +
			"	public static final int ak = 3;\n" +
			"	public static final String aaad = null;\n" +
			"	public static final int aaaf = 1;\n" +
			"	public static final int aaag = 2;\n" +
			"	public static final int aaha = 2;\n" +
			"	static int cxvvb = 1;\n" +
			"	static int z = a;\n" +
			"	String asdff;\n" +
			"	public static String ppfp;\n" +
			"	public static int ppfpged;\n" +
			"	boolean asfadf;\n" +
			"	boolean cbxbx;\n" +
			"	private static long tyt, rrky;\n" +
			"	private static int dgjt, ykjr6y;\n" +
			"	private static final int krykr = 1;\n" +
			"	protected static int rykr5;\n" +
			"	protected static int dhfg;\n" +
			"	private static int dthj;\n" +
			"	private static int fkffy;\n" +
			"	private static String fhfy;\n" +
			"	protected static String fhmf;\n" +
			"	protected String ryur6;\n" +
			"	protected String dhdthd;\n" +
			"	protected String dth5;\n" +
			"	protected String kfyk;\n" +
			"	private String ntd;\n" +
			"	public int asdasdads;\n" +
			"	public static final int dntdr = 7;\n" +
			"	public static final int asys = 1;\n" +
			"	public static final int djd5rwas = 11;\n" +
			"	public static final int dhds45rjd = 12;\n" +
			"	public static final int srws4jd = 13;\n" +
			"	public static final int s4ts = 2;\n" +
			"	public static final int dshes4 = 21;\n" +
			"	public static final int drthed56u = 22;\n" +
			"	public static final int drtye45 = 23;\n" +
			"	public static final int xxbxrb = 3;\n" +
			"	public static final int xfbxr = 31;\n" +
			"	public static final int asgw4y = 32;\n" +
			"	public static final int hdtrhs5r = 33;\n" +
			"	public static final int dshsh = 34;\n" +
			"	public static final int ds45yuwsuy = 4;\n" +
			"	public static final int astgs45rys = 5;\n" +
			"	public static final int srgs4y = 6;\n" +
			"	public static final int srgsryw45 = -6;\n" +
			"	public static final int srgdtgjd45ry = -7;\n" +
			"	public static final int srdjs43t = 1;\n" +
			"	public static final int sedteued5y = 2;\n" +
			"	public static int jrfd6u;\n" +
			"	public static int udf56u;\n" +
			"	private String jf6tu;\n" +
			"	private String jf6tud;\n" +
			"	String bsrh;\n" +
			"	protected X(String a)\n" +
			"	{\n" +
			"	}\n" +
			"	private long sfhdsrhs;\n" +
			"	private boolean qaafasdfs;\n" +
			"	private int sdgsa;\n" +
			"	private long dgse4;\n" +
			"	long sgrdsrg;\n" +
			"	public void gdsthsr()\n" +
			"	{\n" +
			"	}\n" +
			"	private int hsrhs;\n" +
			"	private void hsrhsdsh()\n" +
			"	{\n" +
			"	}\n" +
			"	private String dsfhshsr;\n" +
			"	protected void sfhsh4rsrh()\n" +
			"	{\n" +
			"	}\n" +
			"	protected void shsrhsh()\n" +
			"	{\n" +
			"	}\n" +
			"	protected void sfhstuje56u()\n" +
			"	{\n" +
			"	}\n" +
			"	public void dhdrt6u()\n" +
			"	{\n" +
			"	}\n" +
			"	public void hdtue56u()\n" +
			"	{\n" +
			"	}\n" +
			"	private void htdws4()\n" +
			"	{\n" +
			"	}\n" +
			"	String mfmgf;\n" +
			"	String mgdmd;\n" +
			"	String mdsrh;\n" +
			"	String nmdr;\n" +
			"	private void oyioyio()\n" +
			"	{\n" +
			"	}\n" +
			"	protected static long oyioyreye()\n" +
			"	{\n" +
			"		return 0;\n" +
			"	}\n" +
			"	protected static long etueierh()\n" +
			"	{\n" +
			"		return 0;\n" +
			"	}\n" +
			"	protected static void sdfgsgs()\n" +
			"	{\n" +
			"	}\n" +
			"	protected static void fhsrhsrh()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	long dcggsdg;\n" +
			"	int ssssssgsfh;\n" +
			"	long ssssssgae;\n" +
			"	long ssssssfaseg;\n" +
			"	public void zzzdged()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	String t;\n" +
			"	protected void xxxxxcbsg()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	\n" +
			"	public void vdg()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private int[] fffcvffffffasdfaef;\n" +
			"	private int[] fffcffffffasdfaef;\n" +
			"	private long[] ffcvfffffffasdfaef;\n" +
			"	private int fffffghffffasdfaef; \n" +
			"	private int fffffdffffasdfaef; \n" +
			"	private String ffafffffffasdfaef;\n" +
			"	\n" +
			"	private void fffffffffasdfaef()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private boolean aaaadgasrg;\n" +
			"	private void ddddgaergnj()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private void aaaadgaeg()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void aaaaaaefadfgh()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void addddddddafge()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	static boolean aaaaaaaefae;\n" +
			"	protected void aaaaaaefaef()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private void ggggseae()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private static void ggggggsgsrg()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private static synchronized void ggggggfsfgsr()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private void aaaaaadgaeg()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void aaaaadgaerg()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void bbbbbbsfryghs()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void bfbbbbbbfssreg()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private void bbbbbbfssfb()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private void bbbbbbfssb()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private void bbbbfdssb()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	boolean dggggggdsg;\n" +
			"\n" +
			"	public void hdfhdr()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void dhdrtdrs()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void dghdthtdhd()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void dhdhdtdh()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private void fddhdsh()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private boolean sdffgsdg()\n" +
			"	{\n" +
			"		return true;\n" +
			"	}\n" +
			"			\n" +
			"	private static boolean sdgsdg()\n" +
			"	{\n" +
			"		return false;\n" +
			"	}\n" +
			"	\n" +
			"	protected static final void sfdgsg()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	static int[] fghtys;\n" +
			"\n" +
			"	protected static final int sdsst = 1;\n" +
			"	private static X asdfahnr;\n" +
			"	private static int ssdsdbrtyrtdfhd, ssdsrtyrdbdfhd;\n" +
			"	protected static int ssdsrtydbdfhd, ssdsrtydffbdfhd;\n" +
			"	protected static int ssdrtyhrtysdbdfhd, ssyeghdsdbdfhd;\n" +
			"	private static int ssdsdrtybdfhd, ssdsdehebdfhd;\n" +
			"	protected static int ssdthrtsdbdfhd, ssdshethetdbdfhd;\n" +
			"	private static String sstrdrfhdsdbdfhd;\n" +
			"	protected static int ssdsdbdfhd, ssdsdethbdfhd;\n" +
			"	private static long ssdshdfhchddbdfhd;\n" +
			"	private static long ssdsdvbbdfhd;\n" +
			"	\n" +
			"	\n" +
			"	protected static long ssdsdbdfhd()\n" +
			"	{\n" +
			"		return 0;\n" +
			"	}\n" +
			"\n" +
			"	protected static long sdgsrsbsf()\n" +
			"	{\n" +
			"		return 0;\n" +
			"	}\n" +
			"\n" +
			"	protected static void sfgsfgssghr()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	protected static String sgsgsrg()\n" +
			"	{\n" +
			"		return null;\n" +
			"	}\n" +
			"\n" +
			"	protected static void sdgshsdygra()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private static String sdfsdfs()\n" +
			"	{\n" +
			"		return null;\n" +
			"	}\n" +
			"\n" +
			"	static boolean ryweyer;\n" +
			"\n" +
			"	protected static void adfadfaghsfh()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	protected static void ghasghasrg()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	private static void aadfadfaf()\n" +
			"	{\n" +
			"	}\n" +
			"\n" +
			"	protected static void aadfadf()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private static int fgsfhwr()\n" +
			"	{\n" +
			"		return 0;\n" +
			"	}\n" +
			"\n" +
			"	protected static int gdfgfgrfg()\n" +
			"	{\n" +
			"		return 0;\n" +
			"	}\n" +
			"\n" +
			"	protected static int asdfsfs()\n" +
			"	{\n" +
			"		return 0;\n" +
			"	}\n" +
			"\n" +
			"	protected static String sdgs;\n" +
			"	protected static String sdfsh4e;\n" +
			"	protected static final int gsregs = 0;\n" +
			"	\n" +
			"	protected static String sgsgsd()\n" +
			"	{\n" +
			"		return null;\n" +
			"	}\n" +
			"\n" +
			"	private byte[] sdhqtgwsrh(String rsName, int id)\n" +
			"	{\n" +
			"		String rs = null;\n" +
			"		try\n" +
			"		{\n" +
			"			rs = \"\";\n" +
			"			return null;\n" +
			"		}\n" +
			"		catch (Exception ex)\n" +
			"		{\n" +
			"		}\n" +
			"		finally\n" +
			"		{\n" +
			"			if (rs != null)\n" +
			"			{\n" +
			"				try\n" +
			"				{\n" +
			"					rs.toString();\n" +
			"				}\n" +
			"				catch (Exception ex)\n" +
			"				{\n" +
			"				}\n" +
			"			}\n" +
			"		}\n" +
			"		return null;\n" +
			"	}\n" +
			"\n" +
			"	private void dgagadga()\n" +
			"	{\n" +
			"	}\n" +
			"	\n" +
			"	private String adsyasta;\n" +
			"}\n",
		},
		"");
}
/*
 * Check scenario:  i = i++
 * http://bugs.eclipse.org/bugs/show_bug.cgi?id=84480
 * disabled: https://bugs.eclipse.org/bugs/show_bug.cgi?id=111898
 */
public void test035() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	int f;\n" +
			"	void foo(int i) {\n" +
			"		i = i++;\n" +
			"		i = ++i;\n" +
			"		f = f++;\n" +
			"		f = ++f;\n" +
			"		Zork z;" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 5)\n" +
		"	i = ++i;\n" +
		"	^^^^^^^\n" +
		"The assignment to variable i has no effect\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 7)\n" +
		"	f = ++f;\n" +
		"	^^^^^^^\n" +
		"The assignment to variable f has no effect\n" +
		"----------\n" +
		"3. ERROR in X.java (at line 8)\n" +
		"	Zork z;	}\n" +
		"	^^^^\n" +
		"Zork cannot be resolved to a type\n" +
		"----------\n");
}
public void test036() {
	runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"\n" +
			"	void foo() {\n" +
			"		Object o = new Object();\n" +
			"		do {\n" +
			"			o = null;\n" +
			"		} while (o != null);\n" +
			"		if (o == null) {\n" +
			"			// throw new Exception();\n" +
			"		}\n" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 7)\n" +
		"	} while (o != null);\n" +
		"	         ^\n" +
		"Null comparison always yields false: The variable o can only be null at this location\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 8)\n" +
		"	if (o == null) {\n" +
		"	    ^\n" +
		"Redundant null check: The variable o can only be null at this location\n" +
		"----------\n",
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=93588
public void test037() {
	this.runConformTest(
		new String[] {
			"X.java",
			"public class X extends Object implements Runnable {\n" +
			"	int interval = 5;\n" +
			"	public void run() {\n" +
			"		try {\n" +
			"			Thread.sleep(interval = interval + 100);\n" +
			"			Thread.sleep(interval += 100);\n" +
			"		} catch (InterruptedException e) {\n" +
			"			e.printStackTrace();\n" +
			"		}\n" +
			"	}\n" +
			"\n" +
			"	public static void main(String[] args) {\n" +
			"		new X().run();\n" +
			"	}\n" +
			"}\n",
		},
		"");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111703
public void test038() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"import java.awt.event.*;\n" +
			"\n" +
			"import javax.swing.*;\n" +
			"import javax.swing.event.*;\n" +
			"\n" +
			"public class X {\n" +
			"    JButton myButton = new JButton();\n" +
			"    JTree myTree = new JTree();\n" +
			"    ActionListener action;\n" +
			"    X() {\n" +
			"        action = new ActionListener() {\n" +
			"            public void actionPerformed(ActionEvent e) {\n" +
			"                if (true) {\n" +
			"                    // unlock document\n" +
			"                    final Object document = new Object();\n" +
			"                    myButton.addActionListener(new ActionListener() {\n" +
			"                        private static boolean selectionChanged;\n" +
			"                        static TreeSelectionListener list = new TreeSelectionListener() {\n" +
			"                            public void valueChanged(TreeSelectionEvent e) {\n" +
			"                                selectionChanged = true;\n" +
			"                            }\n" +
			"                        };\n" +
			"                      static {\n" +
			"                      myTree.addTreeSelectionListener(list);\n" +
			"                      }\n" +
			"                        public void actionPerformed(ActionEvent e) {\n" +
			"                            if(!selectionChanged)\n" +
			"                            myButton.removeActionListener(this);\n" +
			"                        }\n" +
			"                    });\n" +
			"                }\n" +
			"            }\n" +
			"        };\n" +
			"    }\n" +
			"    public static void main(String[] args) {\n" +
			"        new X();\n" +
			"    }\n" +
			"\n" +
			"}",
		},
		"----------\n" +
		"1. WARNING in X.java (at line 19)\n" +
		"	public void valueChanged(TreeSelectionEvent e) {\n" +
		"	                                            ^\n" +
		"The parameter e is hiding another local variable defined in an enclosing type scope\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 23)\n" +
		"	static {\n" +
		"	       ^\n" +
		"Cannot define static initializer in inner type new ActionListener(){}\n" +
		"----------\n" +
		"3. ERROR in X.java (at line 24)\n" +
		"	myTree.addTreeSelectionListener(list);\n" +
		"	^^^^^^\n" +
		"Cannot make a static reference to the non-static field myTree\n" +
		"----------\n" +
		"4. WARNING in X.java (at line 26)\n" +
		"	public void actionPerformed(ActionEvent e) {\n" +
		"	                                        ^\n" +
		"The parameter e is hiding another local variable defined in an enclosing type scope\n" +
		"----------\n");
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=111898
public void test039() {
	this.runConformTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public static void main(String[] args) {\n" +
			"		int a = 1;\n" +
			"	    a = a++;\n" +
			"		System.out.print(\"a=\"+a);\n" +
			"		\n" +
			"		int b = 1;\n" +
			"		System.out.print(b = b++);\n" +
			"		System.out.println(\"b=\"+b);\n" +
			"	}\n" +
			"}\n",
		},
		"a=11b=1");
}
// warn upon parameter assignment
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773
public void test040() {
	Map options = getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportParameterAssignment, CompilerOptions.ERROR);
	runNegativeTest(
		// test directory preparation
		true /* flush output directory */,
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  void foo(boolean b) {\n" +
			"    b = false;\n" +
			"  }\n" +
			"}\n",
		},
		// compiler options
		null /* no class libraries */,
		options /* custom options */,
		// compiler results
		"----------\n" + /* expected compiler log */
		"1. ERROR in X.java (at line 3)\n" +
		"	b = false;\n" +
		"	^\n" +
		"The parameter b should not be assigned\n" +
		"----------\n",
		// javac options
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
// warn upon parameter assignment
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773
// diagnose within fake reachable code
public void test041() {
	Map options = getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportParameterAssignment, CompilerOptions.ERROR);
	runNegativeTest(
		// test directory preparation
		true /* flush output directory */,
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  void foo(boolean b) {\n" +
			"    if (false) {\n" +
			"      b = false;\n" +
			"    }\n" +
			"  }\n" +
			"}\n",
		},
		// compiler options
		null /* no class libraries */,
		options /* custom options */,
		// compiler results
		"----------\n" + 
		"1. ERROR in X.java (at line 4)\n" + 
		"	b = false;\n" + 
		"	^\n" + 
		"The parameter b should not be assigned\n" + 
		"----------\n",
		// javac options
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
// warn upon parameter assignment
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773
// diagnose within fake reachable code
public void test042() {
	Map options = getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportParameterAssignment, CompilerOptions.ERROR);
	runNegativeTest(
		// test directory preparation
		true /* flush output directory */,
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  void foo(boolean b) {\n" +
			"    if (true) {\n" +
			"      return;\n" +
			"    }\n" +
			"    b = false;\n" +
			"  }\n" +
			"}\n",
		},
		// compiler options
		null /* no class libraries */,
		options /* custom options */,
		// compiler results
		"----------\n" + /* expected compiler log */
		"1. ERROR in X.java (at line 6)\n" + 
		"	b = false;\n" + 
		"	^\n" + 
		"The parameter b should not be assigned\n" + 
		"----------\n",
		// javac options
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
// warn upon parameter assignment
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=53773
// we only show the 'assignment to final' error here
public void test043() {
	Map options = getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportParameterAssignment, CompilerOptions.ERROR);
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"  void foo(final boolean b) {\n" +
			"    if (false) {\n" +
			"      b = false;\n" +
			"    }\n" +
			"  }\n" +
			"}\n",
		},
		"----------\n" + 
		"1. ERROR in X.java (at line 4)\n" + 
		"	b = false;\n" + 
		"	^\n" + 
		"The final local variable b cannot be assigned. It must be blank and not using a compound assignment\n" + 
		"----------\n",
		null, true, options);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100369
public void test044() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	int length1 = 0;\n" +
			"	{\n" +
			"		length1 = length1; // already detected\n" +
			"	}\n" +
			"	int length2 = length2 = 0; // not detected\n" +
			"	int length3 = 0;\n" +
			"	{\n" +
			"		length3 = length3 = 0; // not detected\n" +
			"	}\n" +
			"	static void foo() {\n" +
			"		int length1 = 0;\n" +
			"		length1 = length1; // already detected\n" +
			"		int length2 = length2 = 0; // not detected\n" +
			"		int length3 = 0;\n" +
			"		length3 = length3 = 0; // not detected\n" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 4)\n" +
		"	length1 = length1; // already detected\n" +
		"	^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length1 has no effect\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 6)\n" +
		"	int length2 = length2 = 0; // not detected\n" +
		"	    ^^^^^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length2 has no effect\n" +
		"----------\n" +
		"3. ERROR in X.java (at line 9)\n" +
		"	length3 = length3 = 0; // not detected\n" +
		"	^^^^^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length3 has no effect\n" +
		"----------\n" +
		"4. ERROR in X.java (at line 13)\n" +
		"	length1 = length1; // already detected\n" +
		"	^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length1 has no effect\n" +
		"----------\n" +
		"5. ERROR in X.java (at line 14)\n" +
		"	int length2 = length2 = 0; // not detected\n" +
		"	    ^^^^^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length2 has no effect\n" +
		"----------\n" +
		"6. ERROR in X.java (at line 16)\n" +
		"	length3 = length3 = 0; // not detected\n" +
		"	^^^^^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length3 has no effect\n" +
		"----------\n",
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=133351
public void test045() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	void foo() {\n" +
			"		int length2 = length2 = 0; // first problem\n" +
			"		int length3 = 0;\n" +
			"		length3 = length3 = 0; // second problem\n" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 3)\n" +
		"	int length2 = length2 = 0; // first problem\n" +
		"	    ^^^^^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length2 has no effect\n" +
		"----------\n" +
		"2. ERROR in X.java (at line 5)\n" +
		"	length3 = length3 = 0; // second problem\n" +
		"	^^^^^^^^^^^^^^^^^^^^^\n" +
		"The assignment to variable length3 has no effect\n" +
		"----------\n",
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200724
public void test046() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public static String s;\n" +
			"	void foo(String s1) {\n" +
			"		X.s = s;" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 4)\n" +
		"	X.s = s;	}\n" +
		"	^^^^^^^\n" +
		"The assignment to variable s has no effect\n" +
		"----------\n",
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200724
public void test047() {
	this.runConformTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public static X MyX;\n" +
			"	public static String s;\n" +
			"	void foo(String s1) {\n" +
			"		X.MyX.s = s;" + // MyX could hold any extending type, hence we must not complain
			"	}\n" +
			"}\n",
		},
		"");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200724
// we could decide that MyX won't change, hence that the assignment
// on line a has no effect, but we accept this as a limit
public void _test048() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public static final X MyX = new X();\n" +
			"	public static String s;\n" +
			"	void foo(String s1) {\n" +
			"		X.MyX.s = s;" + // a
			"	}\n" +
			"}\n",
		},
		"ERR");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200724
// adding a package to the picture
public void test049() {
	this.runNegativeTest(
		new String[] {
			"p/X.java",
			"package p;\n" +
			"public class X {\n" +
			"	public static String s;\n" +
			"	void foo(String s1) {\n" +
			"		p.X.s = s;" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in p\\X.java (at line 5)\n" +
		"	p.X.s = s;	}\n" +
		"	^^^^^^^^^\n" +
		"The assignment to variable s has no effect\n" +
		"----------\n",
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200724
// adding an inner class to the picture
public void test050() {
	this.runNegativeTest(
		new String[] {
			"p/X.java",
			"package p;\n" +
			"public class X {\n" +
			"  class XX {\n" +
			"	 public static String s;\n" +
			"	 void foo(String s1) {\n" +
			"      X.XX.s = s;" +
			"    }\n" +
			"  }\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in p\\X.java (at line 4)\n" +
		"	public static String s;\n" +
		"	                     ^\n" +
		"The field s cannot be declared static in a non-static inner type, unless initialized with a constant expression\n" +
		"----------\n" +
		"2. ERROR in p\\X.java (at line 6)\n" +
		"	X.XX.s = s;    }\n" +
		"	^^^^^^^^^^\n" +
		"The assignment to variable s has no effect\n" +
		"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=200724
// swap lhs and rhs
public void test051() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public static String s;\n" +
			"	void foo(String s1) {\n" +
			"		s = X.s;" +
			"	}\n" +
			"}\n",
		},
		"----------\n" +
		"1. ERROR in X.java (at line 4)\n" +
		"	s = X.s;	}\n" +
		"	^^^^^^^\n" +
		"The assignment to variable s has no effect\n" +
		"----------\n",
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=206017
public void test052() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"  void foo() {\n" +
			"    int i = \"aaa\";\n" +
			"    i = \"bbb\";\n" +
			"  }\n" +
			"}"
			},
			"----------\n" +
			"1. ERROR in X.java (at line 3)\n" +
			"	int i = \"aaa\";\n" +
			"	        ^^^^^\n" +
			"Type mismatch: cannot convert from String to int\n" +
			"----------\n" +
			"2. ERROR in X.java (at line 4)\n" +
			"	i = \"bbb\";\n" +
			"	    ^^^^^\n" +
			"Type mismatch: cannot convert from String to int\n" +
			"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=206017
public void test053() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"  int i = \"aaa\";\n" +
			"  { \n" +
			"    i = \"bbb\";\n" +
			"  }\n" +
			"}"
			},
			"----------\n" +
			"1. ERROR in X.java (at line 2)\n" +
			"	int i = \"aaa\";\n" +
			"	        ^^^^^\n" +
			"Type mismatch: cannot convert from String to int\n" +
			"----------\n" +
			"2. ERROR in X.java (at line 4)\n" +
			"	i = \"bbb\";\n" +
			"	    ^^^^^\n" +
			"Type mismatch: cannot convert from String to int\n" +
			"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235543
public void _test054_definite_unassignment_try_catch() {
	runNegativeTest(
		// test directory preparation
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  public static void main(String args[]) {\n" +
			"    final int i;\n" +
			"    try {\n" +
			"      if (false) {\n" +
			"            i = 0;\n" +
			"            System.out.println(i);\n" +
			"            throw new MyException();\n" +
			"      }\n" +
			"    } catch (Exception e) {\n" +
			"      i = 1; // missing error\n" +
			"    }\n" +
			"  }\n" +
			"}\n" +
			"class MyException extends Exception {\n" +
			"  private static final long serialVersionUID = 1L;\n" +
			"}"
	 	},
		// compiler results
	 	"----------\n" + /* expected compiler log */
		"1. ERROR in X.java (at line 11)\n" +
		"	i = 1;\n" +
		"	^\n" +
		"The final local variable i may already have been assigned\n" +
		"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235543
// variant
public void test055_definite_unassignment_try_catch() {
	runNegativeTest(
		// test directory preparation
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  public static void main(String args[]) {\n" +
			"    final int i;\n" +
			"    try {\n" +
			"      if (false) {\n" +
			"            i = 0;\n" +
			"            System.out.println(i);\n" +
			"            throw new MyException();\n" +
			"      }\n" +
			"    } catch (MyException e) {\n" +
			"      i = 1;\n" +
			"    }\n" +
			"  }\n" +
			"}\n" +
			"class MyException extends Exception {\n" +
			"  private static final long serialVersionUID = 1L;\n" +
			"}"
		},
		// compiler results
		"----------\n" + /* expected compiler log */
		"1. ERROR in X.java (at line 11)\n" + 
		"	i = 1;\n" + 
		"	^\n" + 
		"The final local variable i may already have been assigned\n" + 
		"----------\n",
		// javac options
		JavacTestOptions.EclipseJustification.EclipseBug235543 /* javac test options */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235546
public void test056_definite_unassignment_infinite_for_loop() {
	runConformTest(
		// test directory preparation
		true /* flush output directory */,
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  public static void main(String args[]) {\n" +
			"    final int i;\n" +
			"    for (;true;) {\n" +
			"      if (true) {\n" +
			"        break;\n" +
			"      } else {\n" +
			"        i = 0;\n" +
			"      }\n" +
			"    }\n" +
			"    i = 1;\n" +
			"    System.out.println(i);\n" +
			"  }\n" +
			"}"
	 	},
		// compiler results
	 	null /* do not check compiler log */,
	 	// runtime results
		"1" /* expected output string */,
		"" /* expected error string */,
		JavacTestOptions.EclipseJustification.EclipseBug235546 /* javac test options */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235546
// variant
public void test057_definite_unassignment_infinite_while_loop() {
	runConformTest(
		// test directory preparation
		true /* flush output directory */,
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  public static void main(String args[]) {\n" +
			"    final int i;\n" +
			"    while (true) {\n" +
			"      if (true) {\n" +
			"        break;\n" +
			"      } else {\n" +
			"        i = 0;\n" +
			"      }\n" +
			"    }\n" +
			"    i = 1;\n" +
			"    System.out.println(i);\n" +
			"  }\n" +
			"}"
	 	},
		// compiler results
	 	null /* do not check compiler log */,
	 	// runtime results
		"1" /* expected output string */,
		"" /* expected error string */,
		JavacTestOptions.EclipseJustification.EclipseBug235546 /* javac test options */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235550
public void _test058_definite_unassignment_try_finally() {
	runNegativeTest(
		// test directory preparation
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  public static void main(String args[]) {\n" +
			"    final int i;\n" +
			"    do {\n" +
			"      try {\n" +
			"        break;\n" +
			"      } finally {\n" +
			"        i = 0;\n" +
			"      }\n" +
			"    } while (args.length > 0);\n" +
			"  }\n" +
			"}"
	 	},
		// compiler results
	 	"----------\n" + /* expected compiler log */
		"1. ERROR in X.java...\n" +
		"----------\n");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235555
public void test059_definite_unassignment_assign_in_for_condition() {
	runConformTest(
		// test directory preparation
		true /* flush output directory */,
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  public static void main(String args[]) {\n" +
			"    final int i;\n" +
			"    for (; 0 < (i = 1); i = i + 1) {\n" +
			"      break;\n" +
			"    }\n" +
			"    System.out.println(\"SUCCESS\");\n" +
			"  }\n" +
			"}"
	 	},
		// compiler results
	 	null /* do not check compiler log */,
	 	// runtime results
		"SUCCESS" /* expected output string */,
		"" /* expected error string */,
		JavacTestOptions.JavacHasABug.JavacBug4660984 /* javac test options */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235555
// variant
public void test060_definite_unassignment_assign_in_for_condition() {
	runConformTest(
		// test directory preparation
		new String[] { /* test files */
			"X.java",
			"public class X {\n" +
			"  public static void main(String args[]) {\n" +
			"    final int i;\n" +
			"    for (; 0 < (i = 1);) {\n" +
			"      break;\n" +
			"    }\n" +
			"    System.out.println(\"SUCCESS\");\n" +
			"  }\n" +
			"}"
	 	},
	 	// runtime results
		"SUCCESS" /* expected output string */);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=241841
public void test061() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	java.sql.Date d = new java.util.Date();\n" + 
			"}\n",
		},
		"----------\n" + 
		"1. ERROR in X.java (at line 2)\n" + 
		"	java.sql.Date d = new java.util.Date();\n" + 
		"	                  ^^^^^^^^^^^^^^^^^^^^\n" + 
		"Type mismatch: cannot convert from java.util.Date to java.sql.Date\n" + 
		"----------\n");
}

// challenge widening conversion
public void test062() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" + 
			"  byte b;\n" + 
			"  short s;\n" + 
			"  char c;\n" + 
			"  boolean z;\n" + 
			"  int i;\n" + 
			"  long j;\n" + 
			"  float f;\n" + 
			"  double d;\n" + 
			"void foo() {\n" + 
			"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
			"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
			"	short[] shorts = { b, s, c, z, i, j, f, d, };\n" + 
			"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
			"	int[] ints = { b, s, c, z, i, j, f, d, };\n" + 
			"	long[] longs = { b, s, c, z, i, j, f, d, };\n" + 
			"	float[] floats = { b, s, c, z, i, j, f, d, };\n" + 
			"	double[] doubles = { b, s, c, z, i, j, f, d, };\n" + 
			"}\n" +
			"}\n",
		},
		"----------\n" + 
		"1. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
		"	                       ^\n" + 
		"Type mismatch: cannot convert from byte to boolean\n" + 
		"----------\n" + 
		"2. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
		"	                          ^\n" + 
		"Type mismatch: cannot convert from short to boolean\n" + 
		"----------\n" + 
		"3. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
		"	                             ^\n" + 
		"Type mismatch: cannot convert from char to boolean\n" + 
		"----------\n" + 
		"4. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                   ^\n" + 
		"Type mismatch: cannot convert from int to boolean\n" + 
		"----------\n" + 
		"5. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                      ^\n" + 
		"Type mismatch: cannot convert from long to boolean\n" + 
		"----------\n" + 
		"6. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                         ^\n" + 
		"Type mismatch: cannot convert from float to boolean\n" + 
		"----------\n" + 
		"7. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                            ^\n" + 
		"Type mismatch: cannot convert from double to boolean\n" + 
		"----------\n" + 
		"8. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
		"	                    ^\n" + 
		"Type mismatch: cannot convert from short to byte\n" + 
		"----------\n" + 
		"9. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
		"	                       ^\n" + 
		"Type mismatch: cannot convert from char to byte\n" + 
		"----------\n" + 
		"10. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
		"	                          ^\n" + 
		"Type mismatch: cannot convert from boolean to byte\n" + 
		"----------\n" + 
		"11. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
		"	                             ^\n" + 
		"Type mismatch: cannot convert from int to byte\n" + 
		"----------\n" + 
		"12. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                ^\n" + 
		"Type mismatch: cannot convert from long to byte\n" + 
		"----------\n" + 
		"13. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                   ^\n" + 
		"Type mismatch: cannot convert from float to byte\n" + 
		"----------\n" + 
		"14. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                      ^\n" + 
		"Type mismatch: cannot convert from double to byte\n" + 
		"----------\n" + 
		"15. ERROR in X.java (at line 13)\n" + 
		"	short[] shorts = { b, s, c, z, i, j, f, d, };\n" + 
		"	                         ^\n" + 
		"Type mismatch: cannot convert from char to short\n" + 
		"----------\n" + 
		"16. ERROR in X.java (at line 13)\n" + 
		"	short[] shorts = { b, s, c, z, i, j, f, d, };\n" + 
		"	                            ^\n" + 
		"Type mismatch: cannot convert from boolean to short\n" + 
		"----------\n" + 
		"17. ERROR in X.java (at line 13)\n" + 
		"	short[] shorts = { b, s, c, z, i, j, f, d, };\n" + 
		"	                               ^\n" + 
		"Type mismatch: cannot convert from int to short\n" + 
		"----------\n" + 
		"18. ERROR in X.java (at line 13)\n" + 
		"	short[] shorts = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                  ^\n" + 
		"Type mismatch: cannot convert from long to short\n" + 
		"----------\n" + 
		"19. ERROR in X.java (at line 13)\n" + 
		"	short[] shorts = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                     ^\n" + 
		"Type mismatch: cannot convert from float to short\n" + 
		"----------\n" + 
		"20. ERROR in X.java (at line 13)\n" + 
		"	short[] shorts = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                        ^\n" + 
		"Type mismatch: cannot convert from double to short\n" + 
		"----------\n" + 
		"21. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
		"	                 ^\n" + 
		"Type mismatch: cannot convert from byte to char\n" + 
		"----------\n" + 
		"22. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
		"	                    ^\n" + 
		"Type mismatch: cannot convert from short to char\n" + 
		"----------\n" + 
		"23. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
		"	                          ^\n" + 
		"Type mismatch: cannot convert from boolean to char\n" + 
		"----------\n" + 
		"24. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
		"	                             ^\n" + 
		"Type mismatch: cannot convert from int to char\n" + 
		"----------\n" + 
		"25. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                ^\n" + 
		"Type mismatch: cannot convert from long to char\n" + 
		"----------\n" + 
		"26. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                   ^\n" + 
		"Type mismatch: cannot convert from float to char\n" + 
		"----------\n" + 
		"27. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                      ^\n" + 
		"Type mismatch: cannot convert from double to char\n" + 
		"----------\n" + 
		"28. ERROR in X.java (at line 15)\n" + 
		"	int[] ints = { b, s, c, z, i, j, f, d, };\n" + 
		"	                        ^\n" + 
		"Type mismatch: cannot convert from boolean to int\n" + 
		"----------\n" + 
		"29. ERROR in X.java (at line 15)\n" + 
		"	int[] ints = { b, s, c, z, i, j, f, d, };\n" + 
		"	                              ^\n" + 
		"Type mismatch: cannot convert from long to int\n" + 
		"----------\n" + 
		"30. ERROR in X.java (at line 15)\n" + 
		"	int[] ints = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                 ^\n" + 
		"Type mismatch: cannot convert from float to int\n" + 
		"----------\n" + 
		"31. ERROR in X.java (at line 15)\n" + 
		"	int[] ints = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                    ^\n" + 
		"Type mismatch: cannot convert from double to int\n" + 
		"----------\n" + 
		"32. ERROR in X.java (at line 16)\n" + 
		"	long[] longs = { b, s, c, z, i, j, f, d, };\n" + 
		"	                          ^\n" + 
		"Type mismatch: cannot convert from boolean to long\n" + 
		"----------\n" + 
		"33. ERROR in X.java (at line 16)\n" + 
		"	long[] longs = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                   ^\n" + 
		"Type mismatch: cannot convert from float to long\n" + 
		"----------\n" + 
		"34. ERROR in X.java (at line 16)\n" + 
		"	long[] longs = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                      ^\n" + 
		"Type mismatch: cannot convert from double to long\n" + 
		"----------\n" + 
		"35. ERROR in X.java (at line 17)\n" + 
		"	float[] floats = { b, s, c, z, i, j, f, d, };\n" + 
		"	                            ^\n" + 
		"Type mismatch: cannot convert from boolean to float\n" + 
		"----------\n" + 
		"36. ERROR in X.java (at line 17)\n" + 
		"	float[] floats = { b, s, c, z, i, j, f, d, };\n" + 
		"	                                        ^\n" + 
		"Type mismatch: cannot convert from double to float\n" + 
		"----------\n" + 
		"37. ERROR in X.java (at line 18)\n" + 
		"	double[] doubles = { b, s, c, z, i, j, f, d, };\n" + 
		"	                              ^\n" + 
		"Type mismatch: cannot convert from boolean to double\n" + 
		"----------\n");
}
//challenge narrowing conversion
public void test063() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" + 
			"  byte b;\n" + 
			"  short s;\n" + 
			"  char c;\n" + 
			"  boolean z;\n" + 
			"  int i;\n" + 
			"  long j;\n" + 
			"  float f;\n" + 
			"  double d;\n" + 
			"void foo() {\n" + 
			"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
			"	byte[] bytes = { (byte)b, (byte)s, (byte)c, (byte)z, (byte)i, (byte)j, (byte)f, (byte)d, };\n" + 
			"	short[] shorts = { (short)b, (short)s, (short)c, (short)z, (short)i, (short)j, (short)f, (short)d, };\n" + 
			"	char[] chars = { (char)b, (char)s, (char)c, (char)z, (char)i, (char)j, (char)f, (char)d, };\n" + 
			"	int[] ints = { (int)b, (int)s, (int)c, (int)z, (int)i, (int)j, (int)f, (int)d, };\n" + 
			"	long[] longs = { (long)b, (long)s, (long)c, (long)z, (long)i, (long)j, (long)f, (long)d, };\n" + 
			"	float[] floats = { (float)b, (float)s, (float)c, (float)z, (float)i, (float)j, (float)f, (float)d, };\n" + 
			"	double[] doubles = { (double)b, (double)s, (double)c, (double)z, (double)i, (double)j, (double)f, (double)d, };\n" + 
			"}\n" + 
			"}\n",
		},
		"----------\n" + 
		"1. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
		"	                       ^^^^^^^^^^\n" + 
		"Cannot cast from byte to boolean\n" + 
		"----------\n" + 
		"2. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
		"	                                   ^^^^^^^^^^\n" + 
		"Cannot cast from short to boolean\n" + 
		"----------\n" + 
		"3. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
		"	                                               ^^^^^^^^^^\n" + 
		"Cannot cast from char to boolean\n" + 
		"----------\n" + 
		"4. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
		"	                                                                       ^^^^^^^^^^\n" + 
		"Cannot cast from int to boolean\n" + 
		"----------\n" + 
		"5. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
		"	                                                                                   ^^^^^^^^^^\n" + 
		"Cannot cast from long to boolean\n" + 
		"----------\n" + 
		"6. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
		"	                                                                                               ^^^^^^^^^^\n" + 
		"Cannot cast from float to boolean\n" + 
		"----------\n" + 
		"7. ERROR in X.java (at line 11)\n" + 
		"	boolean[] booleans = { (boolean)b, (boolean)s, (boolean)c, (boolean)z, (boolean)i, (boolean)j, (boolean)f, (boolean)d, };\n" + 
		"	                                                                                                           ^^^^^^^^^^\n" + 
		"Cannot cast from double to boolean\n" + 
		"----------\n" + 
		"8. ERROR in X.java (at line 12)\n" + 
		"	byte[] bytes = { (byte)b, (byte)s, (byte)c, (byte)z, (byte)i, (byte)j, (byte)f, (byte)d, };\n" + 
		"	                                            ^^^^^^^\n" + 
		"Cannot cast from boolean to byte\n" + 
		"----------\n" + 
		"9. ERROR in X.java (at line 13)\n" + 
		"	short[] shorts = { (short)b, (short)s, (short)c, (short)z, (short)i, (short)j, (short)f, (short)d, };\n" + 
		"	                                                 ^^^^^^^^\n" + 
		"Cannot cast from boolean to short\n" + 
		"----------\n" + 
		"10. ERROR in X.java (at line 14)\n" + 
		"	char[] chars = { (char)b, (char)s, (char)c, (char)z, (char)i, (char)j, (char)f, (char)d, };\n" + 
		"	                                            ^^^^^^^\n" + 
		"Cannot cast from boolean to char\n" + 
		"----------\n" + 
		"11. ERROR in X.java (at line 15)\n" + 
		"	int[] ints = { (int)b, (int)s, (int)c, (int)z, (int)i, (int)j, (int)f, (int)d, };\n" + 
		"	                                       ^^^^^^\n" + 
		"Cannot cast from boolean to int\n" + 
		"----------\n" + 
		"12. ERROR in X.java (at line 16)\n" + 
		"	long[] longs = { (long)b, (long)s, (long)c, (long)z, (long)i, (long)j, (long)f, (long)d, };\n" + 
		"	                                            ^^^^^^^\n" + 
		"Cannot cast from boolean to long\n" + 
		"----------\n" + 
		"13. ERROR in X.java (at line 17)\n" + 
		"	float[] floats = { (float)b, (float)s, (float)c, (float)z, (float)i, (float)j, (float)f, (float)d, };\n" + 
		"	                                                 ^^^^^^^^\n" + 
		"Cannot cast from boolean to float\n" + 
		"----------\n" + 
		"14. ERROR in X.java (at line 18)\n" + 
		"	double[] doubles = { (double)b, (double)s, (double)c, (double)z, (double)i, (double)j, (double)f, (double)d, };\n" + 
		"	                                                      ^^^^^^^^^\n" + 
		"Cannot cast from boolean to double\n" + 
		"----------\n");
}
public void test064() {
	this.runConformTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public static void main(String[] args) {\n" +
			"		byte b = (byte)1;\n" +
			"		b += 1;\n" +
			"		System.out.print(b);\n" +
			"	}\n" +
			"}\n",
		},
		"2"
	);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=282891
public void test065() {
	Map options = getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR);
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	protected boolean foo = false;\n" +
			"	public boolean test() {\n" +
			"		return foo || (foo = foo());\n" +
			"	}\n" +
			"	public boolean test2() {\n" +
			"		return foo && (foo = foo());\n" +
			"	}\n" +
			"	public boolean test3() {\n" +
			"		return foo && (foo = foo);\n" +
			"	}\n" +
			"	boolean foo() { return true; }\n" +
			"}"
		},
		"----------\n" + 
		"1. ERROR in X.java (at line 10)\n" + 
		"	return foo && (foo = foo);\n" + 
		"	              ^^^^^^^^^^^\n" + 
		"The assignment to variable foo has no effect\n" + 
		"----------\n",
		null,
		true,
		options
	);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=290376
public void test066() {
	Map options = getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR);
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public boolean test() {\n" +
			"		int i = 1;\n" + 
			"		if (i != (i = 2)) {\n" + 
			"			System.out.println(\"The first warning is unjust.\");\n" + 
			"		}\n" + 
			"		if ((i = 3) != i) {\n" + 
			"			System.out.println(\"The second warning is just.\");\n" + 
			"		}\n" + 
			"		return false;\n" + 
			"	}\n" +
			"}"
		},
		"----------\n" + 
		"1. ERROR in X.java (at line 7)\n" + 
		"	if ((i = 3) != i) {\n" + 
		"	    ^^^^^^^^^^^^\n" + 
		"Comparing identical expressions\n" + 
		"----------\n",
		null,
		true,
		options
	);
}
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=290376
public void test067() {
	Map options = getCompilerOptions();
	options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR);
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X {\n" +
			"	public boolean test() {\n" +
			"		String s = \"Hello World\";\n" + 
			"		if (s != (s = \"\")) {\n" + 
			"			System.out.println(\"The first warning is unjust.\");\n" + 
			"		}\n" + 
			"		if ((s = \"\") != s) {\n" + 
			"			System.out.println(\"The second warning is just.\");\n" + 
			"		}\n" + 
			"		return false;\n" + 
			"	}\n" +
			"}"
		},
		"----------\n" + 
		"1. ERROR in X.java (at line 7)\n" + 
		"	if ((s = \"\") != s) {\n" + 
		"	    ^^^^^^^^^^^^^\n" + 
		"Comparing identical expressions\n" + 
		"----------\n",
		null,
		true,
		options
	);
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=362279
public void test068() {
	this.runNegativeTest(
		new String[] {
			"X.java",
			"public class X  {\n" +
			"	Integer f = 'a'; // Field declaration.\n" +
			"	public Integer main() {\n" +
			"		Integer i = 'a'; // local declaration with initialization.\n" +
			"		i = 'a'; // assignment\n" +
			"                Integer [] ia = new Integer [] { 'a' }; // array initializer.\n" +
			"		return 'a'; // return statement.\n" +
			"		switch (i) {\n" +
			"		case 'a' :   // case statement\n" +
			"		}\n" +
			"	}\n" +
			"}\n"
		},
		this.complianceLevel < ClassFileConstants.JDK1_5 ? 
		"----------\n" + 
		"1. ERROR in X.java (at line 2)\n" + 
		"	Integer f = \'a\'; // Field declaration.\n" + 
		"	            ^^^\n" + 
		"Type mismatch: cannot convert from char to Integer\n" + 
		"----------\n" + 
		"2. ERROR in X.java (at line 4)\n" + 
		"	Integer i = \'a\'; // local declaration with initialization.\n" + 
		"	            ^^^\n" + 
		"Type mismatch: cannot convert from char to Integer\n" + 
		"----------\n" + 
		"3. ERROR in X.java (at line 5)\n" + 
		"	i = \'a\'; // assignment\n" + 
		"	    ^^^\n" + 
		"Type mismatch: cannot convert from char to Integer\n" + 
		"----------\n" + 
		"4. ERROR in X.java (at line 6)\n" + 
		"	Integer [] ia = new Integer [] { \'a\' }; // array initializer.\n" + 
		"	                                 ^^^\n" + 
		"Type mismatch: cannot convert from char to Integer\n" + 
		"----------\n" + 
		"5. ERROR in X.java (at line 7)\n" + 
		"	return \'a\'; // return statement.\n" + 
		"	       ^^^\n" + 
		"Type mismatch: cannot convert from char to Integer\n" + 
		"----------\n" + 
		"6. ERROR in X.java (at line 8)\n" + 
		"	switch (i) {\n" + 
		"	        ^\n" + 
		"Cannot switch on a value of type Integer. Only convertible int values or enum variables are permitted\n" + 
		"----------\n" : 
			"----------\n" + 
			"1. ERROR in X.java (at line 2)\n" + 
			"	Integer f = \'a\'; // Field declaration.\n" + 
			"	            ^^^\n" + 
			"Type mismatch: cannot convert from char to Integer\n" + 
			"----------\n" + 
			"2. ERROR in X.java (at line 4)\n" + 
			"	Integer i = \'a\'; // local declaration with initialization.\n" + 
			"	            ^^^\n" + 
			"Type mismatch: cannot convert from char to Integer\n" + 
			"----------\n" + 
			"3. ERROR in X.java (at line 5)\n" + 
			"	i = \'a\'; // assignment\n" + 
			"	    ^^^\n" + 
			"Type mismatch: cannot convert from char to Integer\n" + 
			"----------\n" + 
			"4. ERROR in X.java (at line 6)\n" + 
			"	Integer [] ia = new Integer [] { \'a\' }; // array initializer.\n" + 
			"	                                 ^^^\n" + 
			"Type mismatch: cannot convert from char to Integer\n" + 
			"----------\n" + 
			"5. ERROR in X.java (at line 7)\n" + 
			"	return \'a\'; // return statement.\n" + 
			"	       ^^^\n" + 
			"Type mismatch: cannot convert from char to Integer\n" + 
			"----------\n" + 
			"6. ERROR in X.java (at line 9)\n" + 
			"	case \'a\' :   // case statement\n" + 
			"	     ^^^\n" + 
			"Type mismatch: cannot convert from char to Integer\n" + 
			"----------\n");
}
public static Class testClass() {
	return AssignmentTest.class;
}
}

Back to the top