Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 209741 Details for
Bug 247564
[compiler][null] Detecting null field reference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed test cleanup
Bug_247564_tests_cleanup.patch (text/plain), 15.39 KB, created by
Stephan Herrmann
on 2012-01-19 07:53:14 EST
(
hide
)
Description:
proposed test cleanup
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2012-01-19 07:53:14 EST
Size:
15.39 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java >index 32bfe8e..5239b1a 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java >@@ -15533,6 +15533,7 @@ public void testBug247564a_3() { > "public class X {\n" + > " Object o;\n" + > " void foo() {\n" + >+ " o = null;\n" + > " }\n" + > " void foo1() {\n" + > " o.toString();\n" + >@@ -15580,7 +15581,7 @@ public void testBug247564a_5() { > " if (field == null) { \n" + > " field = new Object();\n" + > " }\n" + >- " field.toString(); //Pot. NPE\n" + >+ " field.toString(); // Wrong outcome was: Pot. NPE\n" + > " i--;\n" + > " }\n" + > " }\n" + >@@ -16005,7 +16006,7 @@ public void testBug247564b_4() { > " }\n" + > " void foo1() {\n" + > " if (o == null) {\n" + >- " o.toString(); // danger" + >+ " o.toString(); // danger\n" + > " return;\n" + > " }\n" + > " o.toString(); // safe\n" + >@@ -16019,11 +16020,11 @@ public void testBug247564b_4() { > "}\n"}, > "----------\n" + > "1. ERROR in X.java (at line 13)\n" + >- " o.toString(); // danger return;\n" + >+ " o.toString(); // danger\n" + > " ^\n" + > "Null pointer access: The field o can only be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 21)\n" + >+ "2. ERROR in X.java (at line 22)\n" + > " o.toString(); // uncertain\n" + > " ^\n" + > "Potential null pointer access: The field o may be null at this location\n" + >@@ -16075,7 +16076,7 @@ public void testBug247564b_4_2() { > " }\n" + > " void foo1() {\n" + > " if (o == null) {\n" + >- " o.toString(); // danger" + >+ " o.toString(); // danger\n" + > " return;\n" + > " }\n" + > " o.toString(); // safe\n" + >@@ -16089,11 +16090,11 @@ public void testBug247564b_4_2() { > "}\n"}, > "----------\n" + > "1. ERROR in X.java (at line 39)\n" + >- " o.toString(); // danger return;\n" + >+ " o.toString(); // danger\n" + > " ^\n" + > "Null pointer access: The field o can only be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 47)\n" + >+ "2. ERROR in X.java (at line 48)\n" + > " o.toString(); // uncertain\n" + > " ^\n" + > "Potential null pointer access: The field o may be null at this location\n" + >@@ -16128,6 +16129,7 @@ public void testBug247564b_5() { > " if (o == null) {\n" + // don't know o's nullness, so silent > " o.toString();\n" + // report NPE > " }\n" + >+ " local.toString();\n" + // try to diffuse status for o / o2 > " o.toString();\n" + // already reported NPE above. So silent. Same behaviour as 'local' > " if (o2 == null) {\n" + // report always false null check > " o2.toString();\n" + // dead code >@@ -16151,12 +16153,12 @@ public void testBug247564b_5() { > " ^\n" + > "Null pointer access: The field o can only be null at this location\n" + > "----------\n" + >- "4. ERROR in X.java (at line 22)\n" + >+ "4. ERROR in X.java (at line 23)\n" + > " if (o2 == null) {\n" + > " ^^\n" + > "Null comparison always yields false: The field o2 cannot be null at this location\n" + > "----------\n" + >- "5. WARNING in X.java (at line 22)\n" + >+ "5. WARNING in X.java (at line 23)\n" + > " if (o2 == null) {\n" + > " o2.toString();\n" + > " }\n" + >@@ -16166,9 +16168,9 @@ public void testBug247564b_5() { > ); > } > >-//null analysis -- case for static final field initialized inside static block with different values >-//check if the resetting works properly i.e. null status for constant fields should not be >-//reset on method calls. This test is for constructors >+// null analysis -- case for static final field initialized inside static block with different values >+// check if the resetting works properly i.e. null status for constant fields should not be >+// reset on method calls. This test is for constructors > public void testBug247564b_6() { > this.runNegativeTest( > new String[] { >@@ -16193,6 +16195,7 @@ public void testBug247564b_6() { > " if (o == null) {\n" + // don't know o's nullness, so silent > " o.toString();\n" + // report NPE > " }\n" + >+ " local.toString();\n" + // try to diffuse status for o / o2 > " o.toString();\n" + // already reported NPE above. So silent. Same behaviour as 'local' > " if (o2 == null) {\n" + // report always false null check > " o2.toString();\n" + // dead code >@@ -16216,12 +16219,12 @@ public void testBug247564b_6() { > " ^\n" + > "Null pointer access: The field o can only be null at this location\n" + > "----------\n" + >- "4. ERROR in X.java (at line 22)\n" + >+ "4. ERROR in X.java (at line 23)\n" + > " if (o2 == null) {\n" + > " ^^\n" + > "Null comparison always yields false: The field o2 cannot be null at this location\n" + > "----------\n" + >- "5. WARNING in X.java (at line 22)\n" + >+ "5. WARNING in X.java (at line 23)\n" + > " if (o2 == null) {\n" + > " o2.toString();\n" + > " }\n" + >@@ -16231,9 +16234,9 @@ public void testBug247564b_6() { > ); > } > >-//null analysis -- case for static final field initialized inside static block with different values >-//check if the resetting works properly i.e. null status for constant fields should not be >-//reset on method calls. This test is for constructors >+// null analysis -- case for static final field initialized inside static block with different values >+// check if the resetting works properly i.e. null status for constant fields should not be >+// reset on method calls. This test is for constructors > public void testBug247564b_6_2() { > this.runNegativeTest( > new String[] { >@@ -16284,6 +16287,7 @@ public void testBug247564b_6_2() { > " if (o == null) {\n" + // don't know o's nullness, so silent > " o.toString();\n" + // report NPE > " }\n" + >+ " local.toString();\n" + // try to diffuse status for o / o2 > " o.toString();\n" + // already reported NPE above. So silent. Same behaviour as 'local' > " if (o2 == null) {\n" + // report always false null check > " o2.toString();\n" + // dead code >@@ -16307,12 +16311,12 @@ public void testBug247564b_6_2() { > " ^\n" + > "Null pointer access: The field o can only be null at this location\n" + > "----------\n" + >- "4. ERROR in X.java (at line 48)\n" + >+ "4. ERROR in X.java (at line 49)\n" + > " if (o2 == null) {\n" + > " ^^\n" + > "Null comparison always yields false: The field o2 cannot be null at this location\n" + > "----------\n" + >- "5. WARNING in X.java (at line 48)\n" + >+ "5. WARNING in X.java (at line 49)\n" + > " if (o2 == null) {\n" + > " o2.toString();\n" + > " }\n" + >@@ -16349,6 +16353,7 @@ public void testBug247564b_7() { > " if (o1 == null) {\n" + // can't be null, was dereferenced in static initializer > " o1.toString();\n" + // dead > " }\n" + >+ " local.toString();\n" + // try to diffuse status for o1 / o2 > " o1.toString();\n" + // safe > " if (o2 == null) {\n" + // report always false null check > " o2.toString();\n" + // dead code >@@ -16384,12 +16389,12 @@ public void testBug247564b_7() { > " ^^^^^^^^^^^^^^^^^^^^^^\n" + > "Dead code\n" + > "----------\n" + >- "6. ERROR in X.java (at line 22)\n" + >+ "6. ERROR in X.java (at line 23)\n" + > " if (o2 == null) {\n" + > " ^^\n" + > "Null comparison always yields false: The field o2 cannot be null at this location\n" + > "----------\n" + >- "7. WARNING in X.java (at line 22)\n" + >+ "7. WARNING in X.java (at line 23)\n" + > " if (o2 == null) {\n" + > " o2.toString();\n" + > " }\n" + >@@ -16447,6 +16452,7 @@ public void testBug247564b_8() { > " if (o1 == null) {\n" + // report redundant null check > " o1.toString();\n" + // report NPE > " }\n" + >+ " local.toString();\n" + // try to diffuse status for o1 / o2 > " o1.toString();\n" + // already reported NPE above. So silent. Same behaviour as 'local' > " if (o2 == null) {\n" + // report always false null check > " o2.toString();\n" + // dead code >@@ -16477,12 +16483,12 @@ public void testBug247564b_8() { > " ^^\n" + > "Null pointer access: The field o1 can only be null at this location\n" + > "----------\n" + >- "5. ERROR in X.java (at line 40)\n" + >+ "5. ERROR in X.java (at line 41)\n" + > " if (o2 == null) {\n" + > " ^^\n" + > "Null comparison always yields false: The field o2 cannot be null at this location\n" + > "----------\n" + >- "6. WARNING in X.java (at line 40)\n" + >+ "6. WARNING in X.java (at line 41)\n" + > " if (o2 == null) {\n" + > " o2.toString();\n" + > " }\n" + >@@ -16517,6 +16523,7 @@ public void testBug247564b_9() { > " if (o1 == null) {\n" + // report redundant null check > " o1.toString();\n" + // report NPE > " }\n" + >+ " local.toString();\n" + // try to diffuse status for o1 / o2 > " o1.toString();\n" + // already reported NPE above. So silent. Same behaviour as 'local' > " if (o2 == null) {\n" + // report always false null check > " o2.toString();\n" + // dead code >@@ -16547,12 +16554,12 @@ public void testBug247564b_9() { > " ^^\n" + > "Null pointer access: The field o1 can only be null at this location\n" + > "----------\n" + >- "5. ERROR in X.java (at line 18)\n" + >+ "5. ERROR in X.java (at line 19)\n" + > " if (o2 == null) {\n" + > " ^^\n" + > "Null comparison always yields false: The field o2 cannot be null at this location\n" + > "----------\n" + >- "6. WARNING in X.java (at line 18)\n" + >+ "6. WARNING in X.java (at line 19)\n" + > " if (o2 == null) {\n" + > " o2.toString();\n" + > " }\n" + >@@ -16812,26 +16819,6 @@ public void testBug247564d_1() { > ); > } > >-// null analysis -- test redundant instanceof warning for static final fields >-public void testBug247564e_1() { >- this.runNegativeTest( >- new String[] { >- "X.java", >- "public class X {\n" + >- " static final Object o = null;\n" + >- " void foo() {\n" + >- " if (o instanceof X) return;\n" + >- " }\n" + >- "}"}, >- "----------\n" + >- "1. ERROR in X.java (at line 4)\n" + >- " if (o instanceof X) return;\n" + >- " ^\n" + >- "instanceof always yields false: The field o can only be null at this location\n" + >- "----------\n", >- JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >-} >- > // null analysis -- test potential null ptr access warning because of static field access through object returned by method call > public void testBug247564f() { > Map compilerOptions = getCompilerOptions(); >@@ -16935,7 +16922,7 @@ public void testBug247564g() { > " if (this.field99 == null && this.field99.hashCode() == 0){}\n" + > " this.field98 = null;\n" + > " }\n" + >- " if (this.field98.hashCode() == 0) {}\n" + // should not complain >+ " if (this.field98.hashCode() == 0) {}\n" + > " this.field97 = null;\n" + > " if (this.field97.hashCode() == 0) {}\n" + > " if (this.field100.hashCode() == 0) {}\n" + >@@ -16999,7 +16986,7 @@ public void testBug247564h() { > } > > // null analysis -- simple case for field for inner class >-// to make sure that id's of local variables in inner classes dotn conflict with those of fields. >+// to make sure that id's of local variables in inner classes don't conflict with those of fields. > public void testBug247564h_1() { > this.runNegativeTest( > new String[] { >@@ -17027,7 +17014,7 @@ public void testBug247564h_1() { > } > > // null analysis -- simple case for field for inner class >-// to make sure that id's of local variables in inner classes dotn conflict with those of fields. >+// to make sure that id's of local variables in inner classes don't conflict with those of fields. > public void testBug247564h_2() { > this.runNegativeTest( > new String[] { >@@ -17041,14 +17028,14 @@ public void testBug247564h_2() { > " class X2 {\n" + > " Object field4;\n" + > " Object field5;\n" + >- " void goo(Object var) {\n" + >- " if (var == null && field4.toString() == \"\"){}\n" + >- " if (var == null && field5.toString() == \"\"){}\n" + >- " if (field3 == null && field3.toString() == \"\"){}\n" + >- " if (field3 == null && field1.toString() == \"\"){}\n" + >- " }\n" + >+ " void goo(Object var) {\n" + >+ " if (var == null && field4.toString() == \"\"){}\n" + >+ " if (var == null && field5.toString() == \"\"){}\n" + >+ " if (field3 == null && field3.toString() == \"\"){}\n" + >+ " if (field3 == null && field1.toString() == \"\"){}\n" + >+ " }\n" + > " }\n" + >- " Object field22;\n" + >+ " Object field22;\n" + > " }\n" + > "}\n"}, > "----------\n" + >@@ -17085,7 +17072,7 @@ public void testBug247564i_1() { > " if (X.field0 == null && X.field0.toString() == \"\"){}\n" + // warn > " if (this.field0 == null && X.field0.toString() == \"\"){}\n" + // warn > " if (X.field0 == null && this.field0.toString() == \"\"){}\n" + // warn >- " if (X.field0 == null && getX().field0.toString() == \"\"){}\n" + // no warn >+ " if (X.field0 == null && getX().field0.toString() == \"\"){}\n" + // no warn (diffused by getX() call) > " }\n" + > "}\n" + > "class Y{\n" + >@@ -17199,9 +17186,9 @@ public void testBug247564i_3() { > " static Y getY(){ return new Y();}\n" + > " static X getX() { return new X();}\n" + > " static class XInner{\n" + >- " static Object xinnerfield;\n" + >- " XInner getXInner() { return new XInner();\n}" + >- " void goo(Object var) {\n" + >+ " static Object xinnerfield;\n" + >+ " XInner getXInner() { return new XInner();\n}" + >+ " void goo(Object var) {\n" + > " if (new Y().getY().yField1 == null && field0.toString() == \"\"){}\n" + // no warn > " if (getY().yField1 == null && field0.toString() == \"\"){}\n" + // no warn > " if (new Y().getX().field0 == null && field0.toString() == \"\"){}\n" + // warn >@@ -17223,7 +17210,7 @@ public void testBug247564i_3() { > " if (Y.xiny.field1 == null && Y.yField1.toString() == \"\"){}\n" + // no warn > " if (X.field0 == null && X.field0.toString() == \"\"){}\n" + // warn > " if (X.field0 == null && getX().field0.toString() == \"\"){}\n" + // no warn >- " }\n" + >+ " }\n" + > " }\n" + > "}\n" + > "class Y{\n" + >@@ -17643,7 +17630,7 @@ public void testBug247564m() { > this.runNegativeTest( > new String[] { > "X.java", >- "class MyException extends Exception{}" + >+ "class MyException extends Exception{}\n" + > "public class X {\n" + > " private Object f;\n" + > " void gooCalls() throws MyException{}\n" + >@@ -17660,11 +17647,11 @@ public void testBug247564m() { > "}\n"}, > "----------\n" + > "1. WARNING in X.java (at line 1)\n" + >- " class MyException extends Exception{}public class X {\n" + >+ " class MyException extends Exception{}\n" + > " ^^^^^^^^^^^\n" + > "The serializable class MyException does not declare a static final serialVersionUID field of type long\n" + > "----------\n" + >- "2. ERROR in X.java (at line 11)\n" + >+ "2. ERROR in X.java (at line 12)\n" + > " f.toString();\n" + > " ^\n" + > "Potential null pointer access: The field f may be null at this location\n" +
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247564
:
185536
|
185729
|
186938
|
187094
|
188023
|
206514
|
206570
|
206572
|
207019
|
209475
|
209486
|
209552
|
209734
|
209741
|
209759
|
209774
|
209775