View | Details | Raw Unified | Return to bug 236385 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java (+144 lines)
Lines 1418-1423 Link Here
1418
		null /* clientRequestor */,
1418
		null /* clientRequestor */,
1419
		true /* skipJavac */);
1419
		true /* skipJavac */);
1420
}
1420
}
1421
1422
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
1423
public void test050() {
1424
	runTest(
1425
		new String[] {
1426
			"X.java",
1427
			"public class X {\n" +
1428
			"   boolean bar() { return false; } \n" +
1429
			"	public void foo() {" +
1430
			"		if (bar())\n" +
1431
			"			new IllegalArgumentException(\"You must not bar!\");\n" +
1432
			"	}\n" +
1433
			"}",
1434
		},
1435
		false /* expectingCompilerErrors */,
1436
		"----------\n" + 
1437
		"1. WARNING in X.java (at line 4)\n" + 
1438
		"	new IllegalArgumentException(\"You must not bar!\");\n" + 
1439
		"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1440
		"Allocating an instance of a throwable type, which is never used. Perhaps you meant to throw it?\n" + 
1441
		"----------\n",
1442
		"" /* expectedOutputString */,
1443
		"" /* expectedErrorString */,
1444
		false /* forceExecution */,
1445
		null /* classLib */,
1446
		true /* shouldFlushOutputDirectory */, 
1447
		null /* vmArguments */, 
1448
		null /* customOptions */,
1449
		null /* clientRequestor */,
1450
		false /* skipJavac */);
1451
}
1452
1453
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
1454
// warning suppressed
1455
public void test051() {
1456
	if (this.complianceLevel < ClassFileConstants.JDK1_5) return;
1457
	runTest(
1458
		new String[] {
1459
			"X.java",
1460
			"public class X {\n" +
1461
			"   boolean bar() { return false; }\n" +
1462
			"   @SuppressWarnings(\"unused\")\n" +
1463
			"	public void foo() {" +
1464
			"		if (bar())\n" +
1465
			"			new IllegalArgumentException(\"You must not bar!\");\n" +
1466
			"	}\n" +
1467
			"}",
1468
		},
1469
		false /* expectingCompilerErrors */,
1470
		"" /* expectedCompilerLog */,
1471
		"" /* expectedOutputString */,
1472
		"" /* expectedErrorString */,
1473
		false /* forceExecution */,
1474
		null /* classLib */,
1475
		true /* shouldFlushOutputDirectory */, 
1476
		null /* vmArguments */, 
1477
		null /* customOptions */,
1478
		null /* clientRequestor */,
1479
		false /* skipJavac */);
1480
}
1481
1482
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
1483
// warning ignored
1484
public void test052() {
1485
	Map compilerOptions = getCompilerOptions();
1486
	compilerOptions.put(CompilerOptions.OPTION_ReportUnusedThrowableAllocation, CompilerOptions.IGNORE);
1487
	runTest(
1488
		new String[] {
1489
			"X.java",
1490
			"public class X {\n" +
1491
			"   boolean bar() { return false; }\n" +
1492
			"	public void foo() {" +
1493
			"		if (bar())\n" +
1494
			"			new IllegalArgumentException(\"You must not bar!\");\n" +
1495
			"	}\n" +
1496
			"}",
1497
		},
1498
		false /* expectingCompilerErrors */,
1499
		"" /* expectedCompilerLog */,
1500
		"" /* expectedOutputString */,
1501
		"" /* expectedErrorString */,
1502
		false /* forceExecution */,
1503
		null /* classLib */,
1504
		true /* shouldFlushOutputDirectory */, 
1505
		null /* vmArguments */, 
1506
		compilerOptions /* customOptions */,
1507
		null /* clientRequestor */,
1508
		false /* skipJavac */);
1509
}
1510
1511
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
1512
// instance is assigned
1513
public void test053() {
1514
	runTest(
1515
		new String[] {
1516
			"X.java",
1517
			"public class X {\n" +
1518
			"   boolean bar() { return false; }\n" +
1519
			"   Throwable t;\n" +
1520
			"	public void foo() {" +
1521
			"		t = new IllegalArgumentException(\"You must not bar!\");\n" +
1522
			"	}\n" +
1523
			"}",
1524
		},
1525
		false /* expectingCompilerErrors */,
1526
		"" /* expectedCompilerLog */,
1527
		"" /* expectedOutputString */,
1528
		"" /* expectedErrorString */,
1529
		false /* forceExecution */,
1530
		null /* classLib */,
1531
		true /* shouldFlushOutputDirectory */, 
1532
		null /* vmArguments */, 
1533
		null /* customOptions */,
1534
		null /* clientRequestor */,
1535
		false /* skipJavac */);
1536
}
1537
1538
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
1539
// method invoked
1540
public void test054() {
1541
	runTest(
1542
		new String[] {
1543
			"X.java",
1544
			"public class X {\n" +
1545
			"   boolean bar() { return false; }\n" +
1546
			"	public void foo() {" +
1547
			"		if (bar())\n" +
1548
			"			new IllegalArgumentException(\"You must not bar!\").printStackTrace();\n" +
1549
			"	}\n" +
1550
			"}",
1551
		},
1552
		false /* expectingCompilerErrors */,
1553
		"" /* expectedCompilerLog */,
1554
		"" /* expectedOutputString */,
1555
		"" /* expectedErrorString */,
1556
		false /* forceExecution */,
1557
		null /* classLib */,
1558
		true /* shouldFlushOutputDirectory */, 
1559
		null /* vmArguments */, 
1560
		null /* customOptions */,
1561
		null /* clientRequestor */,
1562
		false /* skipJavac */);
1563
}
1564
1421
public static Class testClass() {
1565
public static Class testClass() {
1422
	return FlowAnalysisTest.class;
1566
	return FlowAnalysisTest.class;
1423
}
1567
}

Return to bug 236385