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 155712 Details for
Bug 298139
Invalid 'Potential Null Pointer Access' compiler warning/error with non-short-circuit OR
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]
a possible fix
patchBitwiseAndOR.txt (text/plain), 7.19 KB, created by
Ayushman Jain
on 2010-01-11 02:37:51 EST
(
hide
)
Description:
a possible fix
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-01-11 02:37:51 EST
Size:
7.19 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java,v >retrieving revision 1.68 >diff -u -r1.68 BinaryExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java 26 Nov 2008 17:56:55 -0000 1.68 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java 11 Jan 2010 07:22:27 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 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 >@@ -11,11 +11,17 @@ > package org.eclipse.jdt.internal.compiler.ast; > > import org.eclipse.jdt.internal.compiler.ASTVisitor; >-import org.eclipse.jdt.internal.compiler.impl.*; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >-import org.eclipse.jdt.internal.compiler.codegen.*; >-import org.eclipse.jdt.internal.compiler.flow.*; >-import org.eclipse.jdt.internal.compiler.lookup.*; >+import org.eclipse.jdt.internal.compiler.codegen.BranchLabel; >+import org.eclipse.jdt.internal.compiler.codegen.CodeStream; >+import org.eclipse.jdt.internal.compiler.flow.FlowContext; >+import org.eclipse.jdt.internal.compiler.flow.FlowInfo; >+import org.eclipse.jdt.internal.compiler.impl.Constant; >+import org.eclipse.jdt.internal.compiler.impl.BooleanConstant; >+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; >+import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; >+import org.eclipse.jdt.internal.compiler.lookup.TypeIds; > > public class BinaryExpression extends OperatorExpression { > >@@ -64,6 +70,91 @@ > this.left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits()) > .unconditionalInits(); > } else { >+ if ((this.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT == OR) { >+ Constant cst = this.left.optimizedBooleanConstant(); >+ if (cst instanceof BooleanConstant) { >+ boolean isLeftOptimizedFalse = cst != Constant.NotAConstant && cst.booleanValue() == false; >+ if (isLeftOptimizedFalse) { >+ // FALSE | anything >+ FlowInfo mergedInfo = this.left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits(); >+ mergedInfo = this.right.analyseCode(currentScope, flowContext, mergedInfo); >+ return mergedInfo; >+ } >+ } >+ this.left.checkNPE(currentScope, flowContext, flowInfo); >+ FlowInfo leftInfo = this.left.analyseCode(currentScope, flowContext, flowInfo); >+ this.right.checkNPE(currentScope, flowContext, leftInfo); >+ FlowInfo rightInfo = leftInfo.unconditionalCopy(); >+ FlowInfo rightInfoWhenExpressionFalse = leftInfo.initsWhenFalse().unconditionalCopy(); >+ rightInfoWhenExpressionFalse = this.right.analyseCode(currentScope, flowContext, rightInfoWhenExpressionFalse); >+ rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo); >+ >+ FlowInfo leftInfoWhenTrue = leftInfo.initsWhenTrue().unconditionalCopy(); >+ FlowInfo leftInfoWhenFalse = leftInfo.initsWhenFalse().unconditionalCopy(); >+ >+ //following steps are needed to ensure the initializations of rightInfo are not lost while merging >+ leftInfoWhenTrue.addPotentialInitializationsFrom(rightInfo.unconditionalInitsWithoutSideEffect()); >+ leftInfoWhenFalse.addPotentialInitializationsFrom(rightInfo.unconditionalInitsWithoutSideEffect()); >+ /* Merging as follows: >+ * For the whole expression to be true, conditions: >+ * 1. left is false, right is true >+ * 2. left is true, right is false >+ * 3. left is true, right is true >+ * For the whole expression to be false, condition: >+ * left is false, right is false. >+ */ >+ FlowInfo mergedInfo = FlowInfo.conditional( >+ leftInfoWhenTrue.unconditionalInits().mergedWith( >+ rightInfo.initsWhenTrue().unconditionalInits()).mergedWith( >+ leftInfoWhenTrue.unconditionalInits().mergedWith( >+ rightInfo.initsWhenFalse().unconditionalInits())).mergedWith( >+ leftInfoWhenFalse.unconditionalInits().mergedWith( >+ rightInfo.initsWhenTrue().unconditionalInits())), >+ rightInfoWhenExpressionFalse.initsWhenFalse()); >+ return mergedInfo; >+ } else if ((this.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT == AND) { >+ Constant cst = this.left.optimizedBooleanConstant(); >+ if (cst instanceof BooleanConstant) { >+ boolean isLeftOptimizedTrue = cst != Constant.NotAConstant && cst.booleanValue() == true; >+ if (isLeftOptimizedTrue) { >+ // TRUE & anything >+ FlowInfo mergedInfo = this.left.analyseCode(currentScope, flowContext, flowInfo) >+ .unconditionalInits(); >+ mergedInfo = this.right.analyseCode(currentScope, flowContext, mergedInfo); >+ return mergedInfo; >+ } >+ } >+ this.left.checkNPE(currentScope, flowContext, flowInfo); >+ FlowInfo leftInfo = this.left.analyseCode(currentScope, flowContext, flowInfo); >+ this.right.checkNPE(currentScope, flowContext, leftInfo); >+ FlowInfo rightInfo = leftInfo.initsWhenTrue().unconditionalCopy(); >+ rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo); >+ FlowInfo leftInfoWhenFalse = leftInfo.initsWhenFalse(); >+ // The following step is to make sure that while merging and creating mergedInfo >+ // we don't miss out potentially null candidates in rightInfo >+ // This is because if a variable is definitely null in rightInfo.initsWhenFalse, and its nullness >+ // is not known in leftInfo.initsWhenFalse, the merging will leave it out while taking >+ // intersection of definitely null variables. So we just need to make sure that leftInfo.initsWhenFalse >+ // also knows about it. >+ leftInfoWhenFalse.addPotentialInitializationsFrom(rightInfo.unconditionalInitsWithoutSideEffect()); >+ /* Merging as follows: >+ * For the whole expression to be true, conditions: >+ * left is false, right is false. >+ * For the whole expression to be false, condition: >+ * 1. left is false, right is true >+ * 2. left is true, right is false >+ * 3. left is false, right is false >+ */ >+ FlowInfo mergedInfo = FlowInfo.conditional( >+ rightInfo.safeInitsWhenTrue(), >+ leftInfo.initsWhenTrue().unconditionalInits().mergedWith( >+ rightInfo.initsWhenFalse().unconditionalInits()).mergedWith( >+ leftInfoWhenFalse.unconditionalInits().mergedWith( >+ rightInfo.initsWhenFalse().unconditionalInits())).mergedWith( >+ leftInfoWhenFalse.unconditionalInits().mergedWith( >+ rightInfo.initsWhenTrue().unconditionalInits()))); >+ return mergedInfo; >+ } > this.left.checkNPE(currentScope, flowContext, flowInfo); > flowInfo = this.left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits(); > this.right.checkNPE(currentScope, flowContext, flowInfo);
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 298139
: 155712