Lines 47-53
Link Here
|
47 |
// Only the highest compliance level is run; add the VM argument |
47 |
// Only the highest compliance level is run; add the VM argument |
48 |
// -Dcompliance=1.4 (for example) to lower it if needed |
48 |
// -Dcompliance=1.4 (for example) to lower it if needed |
49 |
static { |
49 |
static { |
50 |
// TESTS_NAMES = new String[] { "test358827" }; |
50 |
// TESTS_NAMES = new String[] { "testBug360328" }; |
51 |
// TESTS_NUMBERS = new int[] { 561 }; |
51 |
// TESTS_NUMBERS = new int[] { 561 }; |
52 |
// TESTS_RANGE = new int[] { 1, 2049 }; |
52 |
// TESTS_RANGE = new int[] { 1, 2049 }; |
53 |
} |
53 |
} |
Lines 15124-15127
Link Here
|
15124 |
true, |
15124 |
true, |
15125 |
compilerOptions); |
15125 |
compilerOptions); |
15126 |
} |
15126 |
} |
|
|
15127 |
// Bug 360328 - [compiler][null] detect null problems in nested code (local class inside a loop) |
15128 |
public void testBug360328() { |
15129 |
Map customOptions = getCompilerOptions(); |
15130 |
customOptions.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR); |
15131 |
customOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.ERROR); |
15132 |
runNegativeTest( |
15133 |
true, /* flushOutputDir */ |
15134 |
new String[] { |
15135 |
"X.java", |
15136 |
"public class X {\n" + |
15137 |
" void print4() {\n" + |
15138 |
" final String s1 = \"\";\n" + |
15139 |
" for (int i=0; i<4; i++)\n" + |
15140 |
" new Runnable() {\n" + |
15141 |
" public void run() {\n" + |
15142 |
" if (s1 != null)\n" + |
15143 |
" s1.toString();\n" + |
15144 |
" }\n" + |
15145 |
" }.run();\n" + |
15146 |
" }\n" + |
15147 |
" void print16(boolean b) {\n" + |
15148 |
" final String s3 = b ? null : \"\";\n" + |
15149 |
" for (int i=0; i<16; i++)\n" + |
15150 |
" new Runnable() {\n" + |
15151 |
" public void run() {\n" + |
15152 |
" s3.toString();\n" + |
15153 |
" }\n" + |
15154 |
" }.run();\n" + |
15155 |
" }\n" + |
15156 |
" void print23() {\n" + |
15157 |
" final String s23 = null;\n" + |
15158 |
" for (int i=0; i<23; i++)\n" + |
15159 |
" new Runnable() {\n" + |
15160 |
" public void run() {\n" + |
15161 |
" s23.toString();\n" + |
15162 |
" }\n" + |
15163 |
" }.run();\n" + |
15164 |
" }\n" + |
15165 |
"}\n", |
15166 |
|
15167 |
}, |
15168 |
null, /* classLibs */ |
15169 |
customOptions, |
15170 |
"----------\n" + |
15171 |
"1. ERROR in X.java (at line 7)\n" + |
15172 |
" if (s1 != null)\n" + |
15173 |
" ^^\n" + |
15174 |
"Redundant null check: The variable s1 cannot be null at this location\n" + |
15175 |
"----------\n" + |
15176 |
"2. ERROR in X.java (at line 17)\n" + |
15177 |
" s3.toString();\n" + |
15178 |
" ^^\n" + |
15179 |
"Potential null pointer access: The variable s3 may be null at this location\n" + |
15180 |
"----------\n" + |
15181 |
"3. ERROR in X.java (at line 26)\n" + |
15182 |
" s23.toString();\n" + |
15183 |
" ^^^\n" + |
15184 |
"Null pointer access: The variable s23 can only be null at this location\n" + |
15185 |
"----------\n", |
15186 |
"",/* expected output */ |
15187 |
"",/* expected error */ |
15188 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
15189 |
} |
15127 |
} |
15190 |
} |