Lines 655-660
Link Here
|
655 |
this.LIBS, |
655 |
this.LIBS, |
656 |
true /* shouldFlush*/); |
656 |
true /* shouldFlush*/); |
657 |
} |
657 |
} |
|
|
658 |
// BugĀ 367203 - [compiler][null] detect assigning null to nonnull argument |
659 |
public void test_nonnull_argument_001() { |
660 |
runNegativeTestWithLibs( |
661 |
new String[] { |
662 |
"ShowNPE2.java", |
663 |
"import org.eclipse.jdt.annotation.NonNullByDefault;\n" + |
664 |
"@NonNullByDefault\n" + |
665 |
"public class ShowNPE2 {\n" + |
666 |
" public Object foo(Object o1, final boolean b) {\n" + |
667 |
" o1 = null; // expect NPE error\n" + |
668 |
" System.out.println(o1.toString()); \n" + |
669 |
" return null; // expect NPE error\n" + |
670 |
" }\n" + |
671 |
"}" |
672 |
}, |
673 |
"----------\n" + |
674 |
"1. ERROR in ShowNPE2.java (at line 5)\n" + |
675 |
" o1 = null; // expect NPE error\n" + |
676 |
" ^^^^\n" + |
677 |
"Type mismatch: required \'@NonNull Object\' but the provided value is null\n" + |
678 |
"----------\n" + |
679 |
"2. ERROR in ShowNPE2.java (at line 7)\n" + |
680 |
" return null; // expect NPE error\n" + |
681 |
" ^^^^\n" + |
682 |
"Type mismatch: required \'@NonNull Object\' but the provided value is null\n" + |
683 |
"----------\n"); |
684 |
} |
685 |
// BugĀ 367203 - [compiler][null] detect assigning null to nonnull argument |
686 |
public void test_nonnull_argument_002() { |
687 |
runNegativeTestWithLibs( |
688 |
new String[] { |
689 |
"ShowNPE2.java", |
690 |
"import org.eclipse.jdt.annotation.NonNullByDefault;\n" + |
691 |
"@NonNullByDefault\n" + |
692 |
"public class ShowNPE2 {\n" + |
693 |
" public Object foo(Object o1, final boolean b) {\n" + |
694 |
" bar(o1); // expecting no problem\n" + |
695 |
" return null; // expect NPE error\n" + |
696 |
" }\n" + |
697 |
" void bar(Object o2) {}\n" + |
698 |
"}" |
699 |
}, |
700 |
"----------\n" + |
701 |
"1. ERROR in ShowNPE2.java (at line 6)\n" + |
702 |
" return null; // expect NPE error\n" + |
703 |
" ^^^^\n" + |
704 |
"Type mismatch: required \'@NonNull Object\' but the provided value is null\n" + |
705 |
"----------\n"); |
706 |
} |
658 |
// assigning potential null to a nonnull local variable |
707 |
// assigning potential null to a nonnull local variable |
659 |
public void test_nonnull_local_001() { |
708 |
public void test_nonnull_local_001() { |
660 |
runNegativeTest( |
709 |
runNegativeTest( |