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 50898 Details for
Bug 154995
[compiler][null] false positive in embedded while/while/break code
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]
Fix plus test case.
org.eclipse.jdt.core_01.txt (text/plain), 10.27 KB, created by
Maxime Daniel
on 2006-09-26 07:50:55 EDT
(
hide
)
Description:
Fix plus test case.
Filename:
MIME Type:
Creator:
Maxime Daniel
Created:
2006-09-26 07:50:55 EDT
Size:
10.27 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java,v >retrieving revision 1.3 >diff -u -r1.3 NullReferenceImplTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java 25 Sep 2006 11:02:40 -0000 1.3 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceImplTests.java 26 Sep 2006 11:49:18 -0000 >@@ -648,10 +648,12 @@ > isDefinitelyNonNull = state.isDefinitelyNonNull(TestLocalVariableBinding.local0), > isDefinitelyNull = state.isDefinitelyNull(TestLocalVariableBinding.local0), > isDefinitelyUnknown = state.isDefinitelyUnknown(TestLocalVariableBinding.local0), >+ isPotentiallyNonNull = state.isPotentiallyNonNull(TestLocalVariableBinding.local0), > isPotentiallyNull = state.isPotentiallyNull(TestLocalVariableBinding.local0), > isPotentiallyUnknown = state.isPotentiallyUnknown(TestLocalVariableBinding.local0), > isProtectedNonNull = state.isProtectedNonNull(TestLocalVariableBinding.local0), > isProtectedNull = state.isProtectedNull(TestLocalVariableBinding.local0), >+ cannotBeDefinitelyNullOrNonNull = state.cannotBeDefinitelyNullOrNonNull(TestLocalVariableBinding.local0), > cannotBeNull = state.cannotBeNull(TestLocalVariableBinding.local0), > canOnlyBeNull = state.canOnlyBeNull(TestLocalVariableBinding.local0); > if (isDefinitelyNonNull >@@ -691,6 +693,9 @@ > || isDefinitelyUnknown || isPotentiallyNull > || isPotentiallyUnknown || isProtectedNonNull > || isProtectedNull) >+ || cannotBeDefinitelyNullOrNonNull != >+ (isPotentiallyUnknown || >+ isPotentiallyNull && isPotentiallyNonNull) > || cannotBeNull != (isProtectedNonNull || > isDefinitelyNonNull) > || canOnlyBeNull != (isProtectedNull || >@@ -717,10 +722,12 @@ > isDefinitelyNonNull = state.isDefinitelyNonNull(TestLocalVariableBinding.local64), > isDefinitelyNull = state.isDefinitelyNull(TestLocalVariableBinding.local64), > isDefinitelyUnknown = state.isDefinitelyUnknown(TestLocalVariableBinding.local64), >+ isPotentiallyNonNull = state.isPotentiallyNonNull(TestLocalVariableBinding.local64), > isPotentiallyNull = state.isPotentiallyNull(TestLocalVariableBinding.local64), > isPotentiallyUnknown = state.isPotentiallyUnknown(TestLocalVariableBinding.local64), > isProtectedNonNull = state.isProtectedNonNull(TestLocalVariableBinding.local64), > isProtectedNull = state.isProtectedNull(TestLocalVariableBinding.local64), >+ cannotBeDefinitelyNullOrNonNull = state.cannotBeDefinitelyNullOrNonNull(TestLocalVariableBinding.local64), > cannotBeNull = state.cannotBeNull(TestLocalVariableBinding.local64), > canOnlyBeNull = state.canOnlyBeNull(TestLocalVariableBinding.local64); > if (isDefinitelyNonNull >@@ -760,6 +767,10 @@ > || isDefinitelyUnknown || isPotentiallyNull > || isPotentiallyUnknown || isProtectedNonNull > || isProtectedNull) >+ || cannotBeDefinitelyNullOrNonNull != >+ (isPotentiallyUnknown || >+ isPotentiallyNull && >+ isPotentiallyNonNull) > || cannotBeNull != (isProtectedNonNull || > isDefinitelyNonNull) > || canOnlyBeNull != (isProtectedNull || >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v >retrieving revision 1.44 >diff -u -r1.44 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 26 Sep 2006 06:12:21 -0000 1.44 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 26 Sep 2006 11:49:32 -0000 >@@ -3759,6 +3759,35 @@ > ""); > } > >+// null analysis - while >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=154995 >+public void test0457_while_nested_break() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void test(String p, String q, boolean b) {\n" + >+ " while (b) {\n" + >+ " String e = q;\n" + >+ " e.trim();\n" + >+ " while (true) {\n" + >+ " if (b)\n" + >+ " e = q;\n" + >+ " else\n" + >+ " e = null;\n" + >+ " if (e == null || p != null) {\n" + >+ " if (e != null) {\n" + // should not complain here >+ " // Do something\n" + >+ " }\n" + >+ " break;\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ "}"}, >+ ""); >+} >+ > // null analysis -- try/finally > public void test0500_try_finally() { > this.runConformTest( >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java,v >retrieving revision 1.57 >diff -u -r1.57 UnconditionalFlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 25 Sep 2006 11:22:00 -0000 1.57 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 26 Sep 2006 11:49:42 -0000 >@@ -470,6 +470,37 @@ > return this; > } > >+final public boolean cannotBeDefinitelyNullOrNonNull(LocalVariableBinding local) { >+ if ((this.tagBits & NULL_FLAG_MASK) == 0 || >+ (local.type.tagBits & TagBits.IsBaseType) != 0) { >+ return false; >+ } >+ int position; >+ if ((position = local.id + this.maxFieldCount) < BitCacheSize) { >+ // use bits >+ return ( >+ (~this.nullBit1 >+ & (this.nullBit2 & this.nullBit3 | this.nullBit4) >+ | ~this.nullBit2 & ~this.nullBit3 & this.nullBit4) >+ & (1L << position)) != 0; >+ } >+ // use extra vector >+ if (this.extra == null) { >+ return false; // if vector not yet allocated, then not initialized >+ } >+ int vectorIndex; >+ if ((vectorIndex = (position / BitCacheSize) - 1) >= >+ this.extra[0].length) { >+ return false; // if not enough room in vector, then not initialized >+ } >+ long a2, a3, a4; >+ return ( >+ (~this.extra[2][vectorIndex] >+ & ((a2 = this.extra[3][vectorIndex]) & (a3 = this.extra[4][vectorIndex]) | (a4 = this.extra[5][vectorIndex])) >+ | ~a2 & ~a3 & a4) >+ & (1L << (position % BitCacheSize))) != 0; >+} >+ > final public boolean cannotBeNull(LocalVariableBinding local) { > if ((this.tagBits & NULL_FLAG_MASK) == 0 || > (local.type.tagBits & TagBits.IsBaseType) != 0) { >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java,v >retrieving revision 1.34 >diff -u -r1.34 FlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 25 Sep 2006 11:22:00 -0000 1.34 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 26 Sep 2006 11:49:39 -0000 >@@ -64,6 +64,22 @@ > } > > /** >+ * Check whether a given local variable is known to be unable to gain a definite >+ * non null or definite null status by the use of an enclosing flow info. The >+ * semantics are that if the current flow info marks the variable as potentially >+ * unknown or else as being both potentially null and potentially non null, >+ * then it won't ever be promoted as definitely null or definitely non null. (It >+ * could still get promoted to definite unknown). >+ * @param local the variable to ckeck >+ * @return true iff this flow info prevents local from being promoted to >+ * definite non null or definite null against an enclosing flow info >+ */ >+public boolean cannotBeDefinitelyNullOrNonNull(LocalVariableBinding local) { >+ return isPotentiallyUnknown(local) || >+ isPotentiallyNonNull(local) && isPotentiallyNull(local); >+} >+ >+/** > * Check whether a given local variable is known to be non null, either because > * it is definitely non null, or because is has been tested against non null. > * @param local the variable to ckeck >Index: compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java,v >retrieving revision 1.34 >diff -u -r1.34 LoopingFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 26 Apr 2006 09:17:30 -0000 1.34 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 26 Sep 2006 11:49:39 -0000 >@@ -332,7 +332,7 @@ > scope.problemReporter().localVariableCanOnlyBeNull(local, reference); > return; > } >- if (flowInfo.isPotentiallyUnknown(local)) { >+ if (flowInfo.cannotBeDefinitelyNullOrNonNull(local)) { > return; > } > if (flowInfo.isPotentiallyNonNull(local)) { >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java,v >retrieving revision 1.52 >diff -u -r1.52 FlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 26 Apr 2006 09:17:30 -0000 1.52 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 26 Sep 2006 11:49:37 -0000 >@@ -503,7 +503,7 @@ > scope.problemReporter().localVariableCannotBeNull(local, reference); > return; > } >- else if (flowInfo.isPotentiallyUnknown(local)) { >+ else if (flowInfo.cannotBeDefinitelyNullOrNonNull(local)) { > return; > } > case CAN_ONLY_NULL: >@@ -511,7 +511,7 @@ > scope.problemReporter().localVariableCanOnlyBeNull(local, reference); > return; > } >- else if (flowInfo.isPotentiallyUnknown(local)) { >+ else if (flowInfo.cannotBeDefinitelyNullOrNonNull(local)) { > return; > } > break;
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 154995
: 50898