Lines 11662-11665
Link Here
|
11662 |
"----------\n", |
11662 |
"----------\n", |
11663 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
11663 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
11664 |
} |
11664 |
} |
|
|
11665 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201 |
11666 |
// unboxing raises an NPE |
11667 |
public void testBug319201() { |
11668 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) |
11669 |
return; |
11670 |
runNegativeTest( |
11671 |
new String[] { |
11672 |
"X.java", |
11673 |
"public class X {\n" + |
11674 |
" public void foo() {\n" + |
11675 |
" Integer i = null;\n" + |
11676 |
" int j = i;\n" + // should warn |
11677 |
" }\n" + |
11678 |
"}"}, |
11679 |
"----------\n" + |
11680 |
"1. ERROR in X.java (at line 4)\n" + |
11681 |
" int j = i;\n" + |
11682 |
" ^\n" + |
11683 |
"Null pointer access: The variable i can only be null at this location\n" + |
11684 |
"----------\n", |
11685 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
11686 |
} |
11687 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201 |
11688 |
//unboxing could raise an NPE |
11689 |
public void testBug319201a() { |
11690 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) |
11691 |
return; |
11692 |
runNegativeTest( |
11693 |
new String[] { |
11694 |
"X.java", |
11695 |
"public class X {\n" + |
11696 |
" public void foo(Integer i) {\n" + |
11697 |
" if (i == null) {};\n" + |
11698 |
" int j;\n" + |
11699 |
" j = i;\n" + // should warn |
11700 |
" }\n" + |
11701 |
"}"}, |
11702 |
"----------\n" + |
11703 |
"1. ERROR in X.java (at line 5)\n" + |
11704 |
" j = i;\n" + |
11705 |
" ^\n" + |
11706 |
"Potential null pointer access: The variable i may be null at this location\n" + |
11707 |
"----------\n", |
11708 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
11709 |
} |
11710 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=319201 |
11711 |
//unboxing raises an NPE |
11712 |
public void testBug319201b() { |
11713 |
if (this.complianceLevel < ClassFileConstants.JDK1_5) |
11714 |
return; |
11715 |
runNegativeTest( |
11716 |
new String[] { |
11717 |
"X.java", |
11718 |
"public class X {\n" + |
11719 |
" public void foo() {\n" + |
11720 |
" Boolean bo = null;;\n" + |
11721 |
" bar(bo);\n" + // should warn |
11722 |
" }\n" + |
11723 |
" void bar(boolean b) {}\n" + |
11724 |
"}"}, |
11725 |
"----------\n" + |
11726 |
"1. ERROR in X.java (at line 4)\n" + |
11727 |
" bar(bo);\n" + |
11728 |
" ^^\n" + |
11729 |
"Null pointer access: The variable bo can only be null at this location\n" + |
11730 |
"----------\n", |
11731 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
11732 |
} |
11665 |
} |
11733 |
} |