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 201437 Details for
Bug 354554
[null] conditional with redundant condition yields weak error message
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Same patch with copyrights updated
Bug_354554_v1.patch (text/plain), 4.64 KB, created by
Stephan Herrmann
on 2011-08-12 16:46:36 EDT
(
hide
)
Description:
Same patch with copyrights updated
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2011-08-12 16:46:36 EDT
Size:
4.64 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java,v >retrieving revision 1.100 >diff -u -r1.100 ConditionalExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 4 Mar 2011 21:22:49 -0000 1.100 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 12 Aug 2011 20:44:15 -0000 >@@ -11,6 +11,7 @@ > * bug 133125 - [compiler][null] need to report the null status of expressions and analyze them simultaneously > * bug 292478 - Report potentially null across variable assignment > * bug 324178 - [null] ConditionalExpression.nullStatus(..) doesn't take into account the analysis of condition itself >+ * bug 354554 - [null] conditional with redundant condition yields weak error message > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -156,6 +157,15 @@ > this.nullStatus = ifTrueNullStatus; > return; > } >+ if (trueBranchInfo.reachMode() != FlowInfo.REACHABLE) { >+ this.nullStatus = ifFalseNullStatus; >+ return; >+ } >+ if (falseBranchInfo.reachMode() != FlowInfo.REACHABLE) { >+ this.nullStatus = ifTrueNullStatus; >+ return; >+ } >+ > // is there a chance of null (or non-null)? -> potentially null etc. > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=133125 > int status = 0; >#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.120 >diff -u -r1.120 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 28 Jul 2011 17:06:24 -0000 1.120 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 12 Aug 2011 20:44:34 -0000 >@@ -17,6 +17,7 @@ > * bug 338303 - Warning about Redundant assignment conflicts with definite assignment > * bug 336428 - [compiler][null] bogus warning "redundant null check" in condition of do {} while() loop > * bug 324178 - [null] ConditionalExpression.nullStatus(..) doesn't take into account the analysis of condition itself >+ * bug 354554 - [null] conditional with redundant condition yields weak error message > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -14898,4 +14899,49 @@ > "----------\n"); > } > } >+// Bug 354554 - [null] conditional with redundant condition yields weak error message >+public void testBug354554() { >+ this.runNegativeTest( >+ new String[] { >+ "Bug354554.java", >+ "public class Bug354554{\n" + >+ " void foo() {\n" + >+ " Object u = new Object();\n" + >+ " Object r = (u == null ? u : null);\n" + // condition is always false - should not spoil subsequent null-analysis >+ " System.out.println(r.toString());\n" + // should strongly complain: r is definitely null >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in Bug354554.java (at line 4)\n" + >+ " Object r = (u == null ? u : null);\n" + >+ " ^\n" + >+ "Null comparison always yields false: The variable u cannot be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in Bug354554.java (at line 5)\n" + >+ " System.out.println(r.toString());\n" + >+ " ^\n" + >+ "Null pointer access: The variable r can only be null at this location\n" + >+ "----------\n"); >+} >+//Bug 354554 - [null] conditional with redundant condition yields weak error message >+public void testBug354554b() { >+ this.runNegativeTest( >+ new String[] { >+ "Bug354554.java", >+ "public class Bug354554{\n" + >+ " void foo() {\n" + >+ " Object u = new Object();\n" + >+ " Object r = (u != null ? u : null);\n" + // condition is always true - should not spoil subsequent null-analysis >+ " System.out.println(r.toString());\n" + // don't complain: r is definitely non-null >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in Bug354554.java (at line 4)\n" + >+ " Object r = (u != null ? u : null);\n" + >+ " ^\n" + >+ "Redundant null check: The variable u cannot be null at this location\n" + >+ "----------\n"); >+} > } >\ No newline at end of file
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 354554
:
201357
| 201437