### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java,v retrieving revision 1.68 diff -u -r1.68 EqualExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 2 May 2007 00:32:32 -0000 1.68 +++ compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 3 Jun 2007 19:54:58 -0000 @@ -39,12 +39,18 @@ if (((this.bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL) { flowContext.recordUsingNullReference(scope, local, reference, FlowContext.CAN_ONLY_NULL_NON_NULL | FlowContext.IN_COMPARISON_NULL, flowInfo); - initsWhenTrue.markAsComparedEqualToNull(local); // from thereon it is set + if (flowInfo.isDefinitelyNonNull(local)) + this.constant = BooleanConstant.fromValue(false); + else + initsWhenTrue.markAsComparedEqualToNull(local); // from thereon it is set initsWhenFalse.markAsComparedEqualToNonNull(local); // from thereon it is set } else { flowContext.recordUsingNullReference(scope, local, reference, FlowContext.CAN_ONLY_NULL_NON_NULL | FlowContext.IN_COMPARISON_NON_NULL, flowInfo); - initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set + if (flowInfo.isDefinitelyNull(local)) + this.constant = BooleanConstant.fromValue(false); + else + initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set initsWhenFalse.markAsComparedEqualToNull(local); // from thereon it is set } break; #P org.eclipse.jdt.core.tests.compiler 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.63 diff -u -r1.63 NullReferenceTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 22 May 2007 08:19:20 -0000 1.63 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 3 Jun 2007 19:55:01 -0000 @@ -1794,10 +1794,10 @@ " ^\n" + "Null comparison always yields false: The variable o cannot be null at this location\n" + "----------\n" + - "2. ERROR in X.java (at line 7)\n" + - " o.toString();\n" + - " ^\n" + - "Potential null pointer access: The variable o may be null at this location\n" + + "2. ERROR in X.java (at line 6)\n" + + " if (o != null) { /* */ }\n" + + " ^\n" + + "Redundant null check: The variable o cannot be null at this location\n" + "----------\n"); } @@ -7360,7 +7360,7 @@ "2. ERROR in X.java (at line 5)\n" + " if (o == null) { };\n" + " ^\n" + - "Null comparison always yields false: The variable o cannot be null at this location\n" + + "Redundant null check: The variable o can only be null at this location\n" + "----------\n"); } } @@ -7528,17 +7528,12 @@ " ^\n" + "Null comparison always yields false: The variable x cannot be null at this location\n" + "----------\n" + - "3. ERROR in X.java (at line 6)\n" + - " x.foo(null); // 3\n" + - " ^\n" + - "Null pointer access: The variable x can only be null at this location\n" + - "----------\n" + - "4. ERROR in X.java (at line 9)\n" + + "3. ERROR in X.java (at line 9)\n" + " } else if (x != null) { // 6\n" + " ^\n" + "Redundant null check: The variable x cannot be null at this location\n" + "----------\n" + - "5. ERROR in X.java (at line 12)\n" + + "4. ERROR in X.java (at line 12)\n" + " x.foo(null); // 8\n" + " ^\n" + "Potential null pointer access: The variable x may be null at this location\n" + @@ -7744,11 +7739,6 @@ " if (x == null) {\n" + " ^\n" + "Null comparison always yields false: The variable x cannot be null at this location\n" + - "----------\n" + - "2. ERROR in X.java (at line 5)\n" + - " x.foo(this);\n" + - " ^\n" + - "Null pointer access: The variable x can only be null at this location\n" + "----------\n"); } @@ -8774,6 +8764,11 @@ " if (o65 == null) { /* */ }\n" + " ^^^\n" + "Null comparison always yields false: The variable o65 cannot be null at this location\n" + + "----------\n" + + "2. ERROR in X.java (at line 19)\n" + + " if (o65 != null) { /* */ }\n" + + " ^^^\n" + + "Redundant null check: The variable o65 cannot be null at this location\n" + "----------\n"); }