Index: src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java,v retrieving revision 1.28 diff -u -w -r1.28 FlowAnalysisTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 2 Apr 2008 11:27:57 -0000 1.28 +++ src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 31 Aug 2008 15:39:48 -0000 @@ -1418,6 +1418,150 @@ null /* clientRequestor */, true /* skipJavac */); } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385 +public void test050() { + runTest( + new String[] { + "X.java", + "public class X {\n" + + " boolean bar() { return false; } \n" + + " public void foo() {" + + " if (bar())\n" + + " new IllegalArgumentException(\"You must not bar!\");\n" + + " }\n" + + "}", + }, + false /* expectingCompilerErrors */, + "----------\n" + + "1. WARNING in X.java (at line 4)\n" + + " new IllegalArgumentException(\"You must not bar!\");\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "Allocating an instance of a throwable type, which is never used. Perhaps you meant to throw it?\n" + + "----------\n", + "" /* expectedOutputString */, + "" /* expectedErrorString */, + false /* forceExecution */, + null /* classLib */, + true /* shouldFlushOutputDirectory */, + null /* vmArguments */, + null /* customOptions */, + null /* clientRequestor */, + false /* skipJavac */); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385 +// warning suppressed +public void test051() { + if (this.complianceLevel < ClassFileConstants.JDK1_5) return; + runTest( + new String[] { + "X.java", + "public class X {\n" + + " boolean bar() { return false; }\n" + + " @SuppressWarnings(\"unused\")\n" + + " public void foo() {" + + " if (bar())\n" + + " new IllegalArgumentException(\"You must not bar!\");\n" + + " }\n" + + "}", + }, + false /* expectingCompilerErrors */, + "" /* expectedCompilerLog */, + "" /* expectedOutputString */, + "" /* expectedErrorString */, + false /* forceExecution */, + null /* classLib */, + true /* shouldFlushOutputDirectory */, + null /* vmArguments */, + null /* customOptions */, + null /* clientRequestor */, + false /* skipJavac */); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385 +// warning ignored +public void test052() { + Map compilerOptions = getCompilerOptions(); + compilerOptions.put(CompilerOptions.OPTION_ReportUnusedThrowableAllocation, CompilerOptions.IGNORE); + runTest( + new String[] { + "X.java", + "public class X {\n" + + " boolean bar() { return false; }\n" + + " public void foo() {" + + " if (bar())\n" + + " new IllegalArgumentException(\"You must not bar!\");\n" + + " }\n" + + "}", + }, + false /* expectingCompilerErrors */, + "" /* expectedCompilerLog */, + "" /* expectedOutputString */, + "" /* expectedErrorString */, + false /* forceExecution */, + null /* classLib */, + true /* shouldFlushOutputDirectory */, + null /* vmArguments */, + compilerOptions /* customOptions */, + null /* clientRequestor */, + false /* skipJavac */); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385 +// instance is assigned +public void test053() { + runTest( + new String[] { + "X.java", + "public class X {\n" + + " boolean bar() { return false; }\n" + + " Throwable t;\n" + + " public void foo() {" + + " t = new IllegalArgumentException(\"You must not bar!\");\n" + + " }\n" + + "}", + }, + false /* expectingCompilerErrors */, + "" /* expectedCompilerLog */, + "" /* expectedOutputString */, + "" /* expectedErrorString */, + false /* forceExecution */, + null /* classLib */, + true /* shouldFlushOutputDirectory */, + null /* vmArguments */, + null /* customOptions */, + null /* clientRequestor */, + false /* skipJavac */); +} + +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385 +// method invoked +public void test054() { + runTest( + new String[] { + "X.java", + "public class X {\n" + + " boolean bar() { return false; }\n" + + " public void foo() {" + + " if (bar())\n" + + " new IllegalArgumentException(\"You must not bar!\").printStackTrace();\n" + + " }\n" + + "}", + }, + false /* expectingCompilerErrors */, + "" /* expectedCompilerLog */, + "" /* expectedOutputString */, + "" /* expectedErrorString */, + false /* forceExecution */, + null /* classLib */, + true /* shouldFlushOutputDirectory */, + null /* vmArguments */, + null /* customOptions */, + null /* clientRequestor */, + false /* skipJavac */); +} + public static Class testClass() { return FlowAnalysisTest.class; }