Lines 52-58
Link Here
|
52 |
private static final Main MAIN = new Main(null/*outWriter*/, null/*errWriter*/, false/*systemExit*/, null/*options*/, null/*progress*/); |
52 |
private static final Main MAIN = new Main(null/*outWriter*/, null/*errWriter*/, false/*systemExit*/, null/*options*/, null/*progress*/); |
53 |
|
53 |
|
54 |
static { |
54 |
static { |
55 |
// TESTS_NAMES = new String[] { "test295_warn_options" }; |
55 |
TESTS_NAMES = new String[] { "test312_warn_options" }; |
56 |
// TESTS_NUMBERS = new int[] { 306 }; |
56 |
// TESTS_NUMBERS = new int[] { 306 }; |
57 |
// TESTS_RANGE = new int[] { 298, -1 }; |
57 |
// TESTS_RANGE = new int[] { 298, -1 }; |
58 |
} |
58 |
} |
Lines 12384-12387
Link Here
|
12384 |
"1 problem (1 warning)", |
12384 |
"1 problem (1 warning)", |
12385 |
true); |
12385 |
true); |
12386 |
} |
12386 |
} |
|
|
12387 |
|
12388 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325342 |
12389 |
// -warn option - regression tests to check option nullAnnot |
12390 |
// Null warnings because of annotations |
12391 |
public void test312_warn_options() { |
12392 |
this.runConformTest( |
12393 |
new String[] { |
12394 |
"X.java", |
12395 |
"import static java.lang.annotation.ElementType.CONSTRUCTOR;\n" + |
12396 |
"import static java.lang.annotation.ElementType.METHOD;\n" + |
12397 |
"import static java.lang.annotation.ElementType.PACKAGE;\n" + |
12398 |
"import static java.lang.annotation.ElementType.PARAMETER;\n" + |
12399 |
"import static java.lang.annotation.ElementType.TYPE;\n" + |
12400 |
"import java.lang.annotation.Documented;\n" + |
12401 |
"import java.lang.annotation.Retention;\n" + |
12402 |
"import java.lang.annotation.RetentionPolicy;\n" + |
12403 |
"import java.lang.annotation.Target;\n" + |
12404 |
"public class X {\n" + |
12405 |
" public void test() { Object o = null; o.toString();}\n" + |
12406 |
" @NonNull Object foo(@Nullable Object o, @NonNull Object o2) {\n" + |
12407 |
" if (o.toString() == \"\"){ return null;}\n" + |
12408 |
" if (o2 == null) {}\n" + |
12409 |
" goo(null).toString();\n" + |
12410 |
" Object local = null;\n" + |
12411 |
" o.toString();\n" + |
12412 |
" Zork z;\n" + |
12413 |
" return null;\n" + |
12414 |
" }\n" + |
12415 |
" @Nullable Object goo(@NonNull Object o2) {\n" + |
12416 |
" return new Object();\n" + |
12417 |
" }\n" + |
12418 |
" @NonNullByDefault Object hoo(Object o2) {\n" + |
12419 |
" if (o2 == null){}\n" + |
12420 |
" if (o2 == null){\n" + |
12421 |
" return null;\n" + |
12422 |
" }\n" + |
12423 |
" return new Object();\n" + |
12424 |
" }\n" + |
12425 |
"}\n"+ |
12426 |
"@Documented\n" + |
12427 |
"@Retention(RetentionPolicy.CLASS)\n" + |
12428 |
"@Target({ METHOD, PARAMETER })\n" + |
12429 |
"@interface NonNull{\n" + |
12430 |
"}\n" + |
12431 |
"@Documented\n" + |
12432 |
"@Retention(RetentionPolicy.CLASS)\n" + |
12433 |
"@Target({ METHOD, PARAMETER })\n" + |
12434 |
"@interface Nullable{\n" + |
12435 |
"}\n" + |
12436 |
"@Documented\n" + |
12437 |
"@Retention(RetentionPolicy.CLASS)\n" + |
12438 |
"@Target({ PACKAGE, TYPE, METHOD, CONSTRUCTOR })\n" + |
12439 |
"@interface NonNullByDefault{\n" + |
12440 |
"}" |
12441 |
}, |
12442 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" |
12443 |
// + " -sourcepath \"" + OUTPUT_DIR + "\"" |
12444 |
+ " -1.5" |
12445 |
+ " -warn:+nullAnnot(p.NonNull|p.Nullable|p.NonNullByDefault) -proc:none -d \"" + OUTPUT_DIR + "\"", |
12446 |
"", |
12447 |
"----------\n" + |
12448 |
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/X.java (at line 4)\n" + |
12449 |
" if (o == null && o.toString() == \"\"){}\n" + |
12450 |
" ^\n" + |
12451 |
"Potential null pointer access: The field o may be null at this location\n" + |
12452 |
"----------\n" + |
12453 |
"1 problem (1 warning)", |
12454 |
true); |
12455 |
} |
12387 |
} |
12456 |
} |