Lines 10-15
Link Here
|
10 |
* Stephan Herrmann - Contributions for |
10 |
* Stephan Herrmann - Contributions for |
11 |
* bug 358827 - [1.7] exception analysis for t-w-r spoils null analysis |
11 |
* bug 358827 - [1.7] exception analysis for t-w-r spoils null analysis |
12 |
* bug 349326 - [1.7] new warning for missing try-with-resources |
12 |
* bug 349326 - [1.7] new warning for missing try-with-resources |
|
|
13 |
* bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points |
13 |
*******************************************************************************/ |
14 |
*******************************************************************************/ |
14 |
package org.eclipse.jdt.core.tests.compiler.regression; |
15 |
package org.eclipse.jdt.core.tests.compiler.regression; |
15 |
|
16 |
|
Lines 4942-4947
Link Here
|
4942 |
true, |
4943 |
true, |
4943 |
options); |
4944 |
options); |
4944 |
} |
4945 |
} |
|
|
4946 |
// Bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points |
4947 |
public void test056throw1() { |
4948 |
Map options = getCompilerOptions(); |
4949 |
options.put(JavaCore.COMPILER_PB_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR); |
4950 |
options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR); |
4951 |
options.put(JavaCore.COMPILER_PB_EXPLICITLY_CLOSED_AUTOCLOSEABLE, CompilerOptions.ERROR); |
4952 |
options.put(JavaCore.COMPILER_PB_DEAD_CODE, CompilerOptions.ERROR); |
4953 |
this.runNegativeTest( |
4954 |
new String[] { |
4955 |
"X.java", |
4956 |
"import java.io.FileReader;\n" + |
4957 |
"public class X {\n" + |
4958 |
" void foo2(boolean a, boolean b, boolean c) throws Exception {\n" + |
4959 |
" FileReader reader = new FileReader(\"file\");\n" + |
4960 |
" if(a)\n" + |
4961 |
" throw new Exception(); //warning 1\n" + |
4962 |
" else if (b)\n" + |
4963 |
" reader.close();\n" + |
4964 |
" else if(c)\n" + |
4965 |
" throw new Exception(); //warning 2\n" + |
4966 |
" reader.close();\n" + |
4967 |
" }\n" + |
4968 |
"}\n" |
4969 |
}, |
4970 |
"----------\n" + |
4971 |
"1. ERROR in X.java (at line 6)\n" + |
4972 |
" throw new Exception(); //warning 1\n" + |
4973 |
" ^^^^^^^^^^^^^^^^^^^^^^\n" + |
4974 |
"Resource leak: \'reader\' is not closed at this location\n" + |
4975 |
"----------\n" + |
4976 |
"2. ERROR in X.java (at line 10)\n" + |
4977 |
" throw new Exception(); //warning 2\n" + |
4978 |
" ^^^^^^^^^^^^^^^^^^^^^^\n" + |
4979 |
"Resource leak: \'reader\' is not closed at this location\n" + |
4980 |
"----------\n", |
4981 |
null, |
4982 |
true, |
4983 |
options); |
4984 |
} |
4945 |
public static Class testClass() { |
4985 |
public static Class testClass() { |
4946 |
return TryWithResourcesStatementTest.class; |
4986 |
return TryWithResourcesStatementTest.class; |
4947 |
} |
4987 |
} |