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 156362 Details for
Bug 299900
[null]Missing potential null warnings for variable on the right of an OR conditional expression
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v0.5 + regression tests
patchNullWarn.txt (text/plain), 5.01 KB, created by
Ayushman Jain
on 2010-01-18 04:22:07 EST
(
hide
)
Description:
proposed fix v0.5 + regression tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-01-18 04:22:07 EST
Size:
5.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java,v >retrieving revision 1.43 >diff -u -r1.43 OR_OR_Expression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java 22 Jul 2009 17:56:52 -0000 1.43 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java 18 Jan 2010 09:11:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -62,9 +62,12 @@ > } > } > rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo); >+ // The definitely null variables in right info when true should not be missed out while merging >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=299900 >+ FlowInfo leftInfoWhenTrueForMerging = leftInfo.initsWhenTrue().unconditionalCopy().addPotentialInitializationsFrom(rightInfo.unconditionalInitsWithoutSideEffect()); > FlowInfo mergedInfo = FlowInfo.conditional( > // merging two true initInfos for such a negative case: if ((t && (b = t)) || f) r = b; // b may not have been initialized >- leftInfo.initsWhenTrue().unconditionalInits().mergedWith( >+ leftInfoWhenTrueForMerging.unconditionalInits().mergedWith( > rightInfo.safeInitsWhenTrue().setReachMode(previousMode).unconditionalInits()), > rightInfo.initsWhenFalse()); > this.mergedInitStateIndex = >#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.83 >diff -u -r1.83 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 19 Nov 2009 15:57:22 -0000 1.83 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 18 Jan 2010 09:11:58 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2009 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10328,4 +10328,60 @@ > "----------\n"); > } > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=299900 >+// Test to verify that null checks are properly reported for the variable(s) >+// in the right expression of an OR condition statement. >+public void testBug299900a() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " void foo(Object foo, Object bar) {\n" + >+ " if(foo == null || bar == null) {\n" + >+ " System.out.println(foo.toString());\n" + >+ " System.out.println(bar.toString());\n" + >+ " }\n" + >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " System.out.println(foo.toString());\n" + >+ " ^^^\n" + >+ "Potential null pointer access: The variable foo may be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 5)\n" + >+ " System.out.println(bar.toString());\n" + >+ " ^^^\n" + >+ "Potential null pointer access: The variable bar may be null at this location\n" + >+ "----------\n"); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=299900 >+// Test to verify that null checks are properly reported for the variable(s) >+// in the right expression of an OR condition statement. >+public void testBug299900b() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class X {\n" + >+ " void foo(Object foo, Object bar) {\n" + >+ " if(foo == null || bar == null) {\n" + >+ " }\n" + >+ " System.out.println(foo.toString());\n" + >+ " System.out.println(bar.toString());\n" + >+ " }\n" + >+ "}"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " System.out.println(foo.toString());\n" + >+ " ^^^\n" + >+ "Potential null pointer access: The variable foo may be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " System.out.println(bar.toString());\n" + >+ " ^^^\n" + >+ "Potential null pointer access: The variable bar may 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
Flags:
Olivier_Thomann
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 299900
: 156362