### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/Block.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java,v retrieving revision 1.43 diff -u -r1.43 Block.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Block.java 14 Oct 2009 18:08:37 -0000 1.43 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Block.java 28 Feb 2011 12:32:02 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -29,7 +29,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // empty block if (this.statements == null) return flowInfo; - int complaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; + int complaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; for (int i = 0, max = this.statements.length; i < max; i++) { Statement stat = this.statements[i]; if ((complaintLevel = stat.complainIfUnreachable(flowInfo, this.scope, complaintLevel)) < Statement.COMPLAINED_UNREACHABLE) { 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.98 diff -u -r1.98 ConditionalExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 14 Jan 2011 17:02:24 -0000 1.98 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 28 Feb 2011 12:32:02 -0000 @@ -43,7 +43,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { - int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; + int initialComplaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; Constant cst = this.condition.optimizedBooleanConstant(); boolean isConditionOptimizedTrue = cst != Constant.NotAConstant && cst.booleanValue() == true; boolean isConditionOptimizedFalse = cst != Constant.NotAConstant && cst.booleanValue() == false; Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java,v retrieving revision 1.69 diff -u -r1.69 ForStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 23 Aug 2010 08:41:25 -0000 1.69 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 28 Feb 2011 12:32:02 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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,7 +62,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { this.breakLabel = new BranchLabel(); this.continueLabel = new BranchLabel(); - int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; + int initialComplaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; // process the initializations if (this.initializations != null) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java,v retrieving revision 1.64 diff -u -r1.64 ForeachStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 9 Aug 2010 04:09:41 -0000 1.64 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 28 Feb 2011 12:32:02 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -76,7 +76,7 @@ // initialize break and continue labels this.breakLabel = new BranchLabel(); this.continueLabel = new BranchLabel(); - int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; + int initialComplaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; // process the element variable and collection this.collection.checkNPE(currentScope, flowContext, flowInfo); Index: compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java,v retrieving revision 1.69 diff -u -r1.69 IfStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java 12 Aug 2010 16:58:28 -0000 1.69 +++ compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java 28 Feb 2011 12:32:02 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -55,7 +55,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // process the condition FlowInfo conditionFlowInfo = this.condition.analyseCode(currentScope, flowContext, flowInfo); - int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; + int initialComplaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; Constant cst = this.condition.optimizedBooleanConstant(); if ((this.condition.implicitConversion & TypeIds.UNBOXING) != 0) { @@ -73,13 +73,13 @@ if (isConditionOptimizedTrue) { elseFlowInfo.setReachMode(FlowInfo.UNREACHABLE); } - if (((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) && - ((thenFlowInfo.tagBits & FlowInfo.UNREACHABLE) != 0)) { + if (((flowInfo.tagBits & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) == 0) && + ((thenFlowInfo.tagBits & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0)) { // Mark then block as unreachable // No need if the whole if-else construct itself lies in unreachable code this.bits |= ASTNode.IsThenStatementUnreachable; - } else if (((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) && - ((elseFlowInfo.tagBits & FlowInfo.UNREACHABLE) != 0)) { + } else if (((flowInfo.tagBits & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) == 0) && + ((elseFlowInfo.tagBits & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0)) { // Mark else block as unreachable // No need if the whole if-else construct itself lies in unreachable code this.bits |= ASTNode.IsElseStatementUnreachable; Index: compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java,v retrieving revision 1.79 diff -u -r1.79 MethodDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 16 Jan 2011 22:43:21 -0000 1.79 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 28 Feb 2011 12:32:02 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -97,7 +97,7 @@ } // propagate to statements if (this.statements != null) { - int complaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) == 0 ? Statement.NOT_COMPLAINED : Statement.COMPLAINED_FAKE_REACHABLE; + int complaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) == 0 ? Statement.NOT_COMPLAINED : Statement.COMPLAINED_FAKE_REACHABLE; for (int i = 0, count = this.statements.length; i < count; i++) { Statement stat = this.statements[i]; if ((complaintLevel = stat.complainIfUnreachable(flowInfo, this.scope, complaintLevel)) < Statement.COMPLAINED_UNREACHABLE) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java,v retrieving revision 1.51 diff -u -r1.51 Statement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java 22 Jan 2011 23:39:25 -0000 1.51 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java 28 Feb 2011 12:32:02 -0000 @@ -71,7 +71,7 @@ // Report an error if necessary (if even more unreachable than previously reported // complaintLevel = 0 if was reachable up until now, 1 if fake reachable (deadcode), 2 if fatal unreachable (error) public int complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, int previousComplaintLevel) { - if ((flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0) { + if ((flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0) { this.bits &= ~ASTNode.IsReachable; if (flowInfo == FlowInfo.DEAD_END) { if (previousComplaintLevel < COMPLAINED_UNREACHABLE) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java,v retrieving revision 1.79 diff -u -r1.79 SwitchStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 12 Aug 2010 16:58:28 -0000 1.79 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java 28 Feb 2011 12:32:02 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -61,7 +61,7 @@ this.preSwitchInitStateIndex = currentScope.methodScope().recordInitializationStates(flowInfo); int caseIndex = 0; if (this.statements != null) { - int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; + int initialComplaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; int complaintLevel = initialComplaintLevel; int fallThroughState = CASE; for (int i = 0, max = this.statements.length; i < max; i++) { Index: compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java,v retrieving revision 1.66 diff -u -r1.66 WhileStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java 23 Aug 2010 08:41:25 -0000 1.66 +++ compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java 28 Feb 2011 12:32:03 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -41,7 +41,7 @@ this.breakLabel = new BranchLabel(); this.continueLabel = new BranchLabel(); - int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; + int initialComplaintLevel = (flowInfo.reachMode() & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED; Constant cst = this.condition.constant; boolean isConditionTrue = cst != Constant.NotAConstant && cst.booleanValue() == true; 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.68 diff -u -r1.68 FlowContext.java --- compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 1 Sep 2010 15:49:57 -0000 1.68 +++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 28 Feb 2011 12:32:03 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -565,7 +565,7 @@ */ public void recordUsingNullReference(Scope scope, LocalVariableBinding local, Expression reference, int checkType, FlowInfo flowInfo) { - if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0 || + if ((flowInfo.tagBits & (FlowInfo.UNREACHABLE|FlowInfo.UNREACHABLE_BY_NULLANALYSIS)) != 0 || flowInfo.isDefinitelyUnknown(local)) { return; } @@ -578,14 +578,14 @@ scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); } if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { - flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); + flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); } } else { if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { scope.problemReporter().localVariableNonNullComparedToNull(local, reference); } if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { - flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); + flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); } } return; @@ -609,7 +609,7 @@ scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); } if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { - flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); + flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); } return; case FlowContext.IN_COMPARISON_NON_NULL: @@ -621,7 +621,7 @@ scope.problemReporter().localVariableNullComparedToNonNull(local, reference); } if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { - flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); + flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); } return; case FlowContext.IN_ASSIGNMENT: 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.45 diff -u -r1.45 FlowInfo.java --- compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 16 Dec 2010 13:02:30 -0000 1.45 +++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 28 Feb 2011 12:32:03 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -24,6 +24,8 @@ public final static int REACHABLE = 0; public final static int UNREACHABLE = 1; public final static int NULL_FLAG_MASK = 2; + public static final int UNREACHABLE_BY_NULLANALYSIS = 4; + public final static int UNKNOWN = 1; public final static int NULL = 2; @@ -456,13 +458,13 @@ } /** - * Return REACHABLE if this flow info is reachable, UNREACHABLE + * Return REACHABLE if this flow info is reachable, UNREACHABLE|UNREACHABLE_BY_NULLANALYSIS * else. - * @return REACHABLE if this flow info is reachable, UNREACHABLE + * @return REACHABLE if this flow info is reachable, UNREACHABLE|UNREACHABLE_BY_NULLANALYSIS * else */ public int reachMode() { - return this.tagBits & UNREACHABLE; + return this.tagBits & (UNREACHABLE|UNREACHABLE_BY_NULLANALYSIS); } /** 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.72 diff -u -r1.72 UnconditionalFlowInfo.java --- compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 19 Jan 2011 05:29:54 -0000 1.72 +++ compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 28 Feb 2011 12:32:03 -0000 @@ -1563,6 +1563,17 @@ na1, na2, na3, na4, nb1, nb2, nb3, nb4, b1, b2, b3, b4; + if ((otherInits.tagBits & FlowInfo.UNREACHABLE_BY_NULLANALYSIS) != 0) { + otherHasNulls = false; // skip merging, otherInits is unreachable by null analysis + } else { + if ((this.tagBits & FlowInfo.UNREACHABLE_BY_NULLANALYSIS) != 0) { // directly copy if this is unreachable by null analysis + this.nullBit1 = otherInits.nullBit1; + this.nullBit2 = otherInits.nullBit2; + this.nullBit3 = otherInits.nullBit3; + this.nullBit4 = otherInits.nullBit4; + thisHadNulls = false; + thisHasNulls = otherHasNulls; + } else if (thisHadNulls) { if (otherHasNulls) { this.nullBit1 = (a2 = this.nullBit2) & (a3 = this.nullBit3) @@ -1636,6 +1647,7 @@ this.nullBit3 != 0 || this.nullBit4 != 0; } + } // treating extra storage if (this.extra != null || otherInits.extra != null) { @@ -1858,6 +1870,8 @@ } if (reachMode == REACHABLE ) { this.tagBits &= ~UNREACHABLE; + } else if (reachMode == UNREACHABLE_BY_NULLANALYSIS) { + this.tagBits |= UNREACHABLE_BY_NULLANALYSIS; // don't interfere with definite assignment analysis } else { if ((this.tagBits & UNREACHABLE) == 0) { // reset optional inits when becoming unreachable