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 209759 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]
test & fix re comment 161
Bug_247564_resetNullInfoForFields-fix.patch (text/plain), 10.48 KB, created by
Stephan Herrmann
on 2012-01-19 11:59:58 EST
(
hide
)
Description:
test & fix re comment 161
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2012-01-19 11:59:58 EST
Size:
10.48 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 22562bf..846408f 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 >@@ -49,7 +49,7 @@ public NullReferenceTest(String name) { > // Only the highest compliance level is run; add the VM argument > // -Dcompliance=1.4 (for example) to lower it if needed > static { >-// TESTS_NAMES = new String[] { "testBug247564k_3" }; >+// TESTS_NAMES = new String[] { "testBug247564b_1" }; > // TESTS_NUMBERS = new int[] { 561 }; > // TESTS_RANGE = new int[] { 1, 2049 }; > } >@@ -16562,6 +16562,219 @@ public void testBug247564b_9() { > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } > >+// 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. >+// Boundary condition: field <boundary> constant local >+public void testBug247564b_10() { >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ false, >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ "Object field0, \n" + >+ "field1, field2, field3, field4, \n" + >+ "field5, field6, field7, field8, \n" + >+ "field9, field10, field11, field12, \n" + >+ "field13, field14, field15, field16, \n" + >+ "field17, field18, field19, field20, \n" + >+ "field21, field22, field23, field24, \n" + >+ "field25, field26, field27, field28, \n" + >+ "field29, field30, field31, field32, \n" + >+ "field33, field34, field35, field36, \n" + >+ "field37, field38, field39, field40, \n" + >+ "field41, field42, field43, field44, \n" + >+ "field45, field46, field47, field48, \n" + >+ "field49, field50, field51, field52, \n" + >+ "field53, field54, field55, field56, \n" + >+ "field57, field58, field59, field60, \n" + >+ "field61, field62, field63;\n" + >+ "static final Object static64 = null;\n" + >+ " void foo1(Object local65) {\n" + >+ " if (field63 == null) {\n" + >+ " field63.toString(); // report NPE\n" + >+ " }\n" + >+ " if (static64 == null) { // redundant\n" + >+ " static64.toString(); // report NPE\n" + >+ " }\n" + >+ " if (local65 == null) {\n" + >+ " local65.toString(); // report NPE\n" + >+ " }\n" + >+ " if (field63 == null) {\n" + >+ " this.toString();\n" + >+ " field63.toString();\n" + // wiped by method call >+ " }\n" + >+ " if (static64 == null) { // always false\n" + // because we're past static64.toString() >+ " this.toString(); // dead\n" + >+ " static64.toString();\n" + >+ " }\n" + >+ " if (local65 == null) { // alwayws false\n" + // because we're past local65.toString() >+ " this.toString(); // dead\n" + >+ " local65.toString();\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"}, >+ null, >+ compilerOptions, >+ "----------\n" + >+ "1. ERROR in X.java (at line 22)\n" + >+ " field63.toString(); // report NPE\n" + >+ " ^^^^^^^\n" + >+ "Potential null pointer access: The field field63 may be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 24)\n" + >+ " if (static64 == null) { // redundant\n" + >+ " ^^^^^^^^\n" + >+ "Redundant null check: The field static64 can only be null at this location\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 25)\n" + >+ " static64.toString(); // report NPE\n" + >+ " ^^^^^^^^\n" + >+ "Null pointer access: The field static64 can only be null at this location\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 28)\n" + >+ " local65.toString(); // report NPE\n" + >+ " ^^^^^^^\n" + >+ "Null pointer access: The variable local65 can only be null at this location\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 34)\n" + >+ " if (static64 == null) { // always false\n" + >+ " ^^^^^^^^\n" + >+ "Null comparison always yields false: The field static64 cannot be null at this location\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 34)\n" + >+ " if (static64 == null) { // always false\n" + >+ " this.toString(); // dead\n" + >+ " static64.toString();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "7. ERROR in X.java (at line 38)\n" + >+ " if (local65 == null) { // alwayws false\n" + >+ " ^^^^^^^\n" + >+ "Null comparison always yields false: The variable local65 cannot be null at this location\n" + >+ "----------\n" + >+ "8. WARNING in X.java (at line 38)\n" + >+ " if (local65 == null) { // alwayws false\n" + >+ " this.toString(); // dead\n" + >+ " local65.toString();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// 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. >+// Boundary condition: constant field <boundary> local >+public void testBug247564b_11() { >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, CompilerOptions.IGNORE); >+ this.runNegativeTest( >+ false, >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ "Object field0, \n" + >+ "field1, field2, field3, field4, \n" + >+ "field5, field6, field7, field8, \n" + >+ "field9, field10, field11, field12, \n" + >+ "field13, field14, field15, field16, \n" + >+ "field17, field18, field19, field20, \n" + >+ "field21, field22, field23, field24, \n" + >+ "field25, field26, field27, field28, \n" + >+ "field29, field30, field31, field32, \n" + >+ "field33, field34, field35, field36, \n" + >+ "field37, field38, field39, field40, \n" + >+ "field41, field42, field43, field44, \n" + >+ "field45, field46, field47, field48, \n" + >+ "field49, field50, field51, field52, \n" + >+ "field53, field54, field55, field56, \n" + >+ "field57, field58, field59, field60, \n" + >+ "field61;\n" + >+ "static final Object static62 = null;\n" + >+ "Object field63;" + >+ " void foo1(Object local64) {\n" + >+ " if (static62 == null) { // redundant\n" + >+ " static62.toString(); // report NPE\n" + >+ " }\n" + >+ " if (field63 == null) {\n" + >+ " field63.toString(); // report NPE\n" + >+ " }\n" + >+ " if (local64 == null) {\n" + >+ " local64.toString(); // report NPE\n" + >+ " }\n" + >+ " if (static62 == null) { // always false\n" + // because we're past static64.toString() >+ " this.toString(); // dead\n" + >+ " static62.toString();\n" + >+ " }\n" + >+ " if (field63 == null) {\n" + >+ " this.toString(); //\n" + >+ " field63.toString();\n" + // wiped by method call >+ " }\n" + >+ " if (local64 == null) { // alwayws false\n" + // because we're past local64.toString() >+ " this.toString(); // dead\n" + >+ " local64.toString();\n" + >+ " }\n" + >+ " }\n" + >+ "}\n"}, >+ null, >+ compilerOptions, >+ "----------\n" + >+ "1. ERROR in X.java (at line 21)\n" + >+ " if (static62 == null) { // redundant\n" + >+ " ^^^^^^^^\n" + >+ "Redundant null check: The field static62 can only be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 22)\n" + >+ " static62.toString(); // report NPE\n" + >+ " ^^^^^^^^\n" + >+ "Null pointer access: The field static62 can only be null at this location\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 25)\n" + >+ " field63.toString(); // report NPE\n" + >+ " ^^^^^^^\n" + >+ "Potential null pointer access: The field field63 may be null at this location\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 28)\n" + >+ " local64.toString(); // report NPE\n" + >+ " ^^^^^^^\n" + >+ "Null pointer access: The variable local64 can only be null at this location\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 30)\n" + >+ " if (static62 == null) { // always false\n" + >+ " ^^^^^^^^\n" + >+ "Null comparison always yields false: The field static62 cannot be null at this location\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 30)\n" + >+ " if (static62 == null) { // always false\n" + >+ " this.toString(); // dead\n" + >+ " static62.toString();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "7. ERROR in X.java (at line 38)\n" + >+ " if (local64 == null) { // alwayws false\n" + >+ " ^^^^^^^\n" + >+ "Null comparison always yields false: The variable local64 cannot be null at this location\n" + >+ "----------\n" + >+ "8. WARNING in X.java (at line 38)\n" + >+ " if (local64 == null) { // alwayws false\n" + >+ " this.toString(); // dead\n" + >+ " local64.toString();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ > // null analysis -- fields in synchronized methods > // check that null analysis for fields in synchronized methods > // behave as it does in ordinary methods. >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java >index 4154cf4..d3bb7e2 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java >@@ -1520,7 +1520,8 @@ public void resetNullInfo(VariableBinding local) { > > public void resetNullInfoForFields() { > if (this != DEAD_END) { >- long mask = (-1L << this.maxFieldCount) | this.constantFieldsMask; >+ long mask = this.maxFieldCount < BitCacheSize ? (-1L << this.maxFieldCount) : 0L; >+ mask |= this.constantFieldsMask; > // first reset normal bits: > this.nullBit1 |= ~mask; > this.nullBit2 &= mask;
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