diff options
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow')
9 files changed, 47 insertions, 47 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java index 256bb09b7..51fcfcb46 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java @@ -121,7 +121,7 @@ public boolean isDefinitelyUnknown(LocalVariableBinding local) { @Override public boolean hasNullInfoFor(LocalVariableBinding local) { - return this.initsWhenTrue.hasNullInfoFor(local) + return this.initsWhenTrue.hasNullInfoFor(local) || this.initsWhenFalse.hasNullInfoFor(local); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java index f29648064..0c958db28 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java @@ -50,7 +50,7 @@ public class ExceptionHandlingFlowContext extends FlowContext { int[] isReached; int[] isNeeded; // WARNING: This is an array that maps to catch blocks, not caught exceptions (which could be more than catch blocks in a multi-catch block) - UnconditionalFlowInfo[] initsOnExceptions; + UnconditionalFlowInfo[] initsOnExceptions; ObjectCache indexes = new ObjectCache(); boolean isMethodContext; @@ -82,7 +82,7 @@ public ExceptionHandlingFlowContext( FlowContext initializationParent, BlockScope scope, FlowInfo flowInfo) { - this(parent, tryStatement, handledExceptions, exceptionToCatchBlockMap, + this(parent, tryStatement, handledExceptions, exceptionToCatchBlockMap, tryStatement.catchArguments, initializationParent, scope, flowInfo.unconditionalInits()); UnconditionalFlowInfo unconditionalCopy = flowInfo.unconditionalCopy(); unconditionalCopy.iNBit = -1L; @@ -193,7 +193,7 @@ public void complainIfUnusedExceptionHandlers(BlockScope scope,TryStatement tryS } } -private ASTNode getExceptionType(int index) { +private ASTNode getExceptionType(int index) { if (this.exceptionToCatchBlockMap == null) { return this.catchArguments[index].type; } @@ -204,8 +204,8 @@ private ASTNode getExceptionType(int index) { for (int i = 0, len = typeRefs.length; i < len; i++) { TypeReference typeRef = typeRefs[i]; if (TypeBinding.equalsEquals(typeRef.resolvedType, this.handledExceptions[index])) return typeRef; - } - } + } + } return node; } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java index 5cd681981..cd075750e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java @@ -224,7 +224,7 @@ public void complainOnDeferredChecks(FlowInfo flowInfo, BlockScope scope) { } break; case IN_UNBOXING: - checkUnboxing(scope, (Expression) location, flowInfo); + checkUnboxing(scope, (Expression) location, flowInfo); break; default: // should not happen diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java index 8fb978d36..f74ee32a4 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java @@ -70,7 +70,7 @@ public class FlowContext implements TypeConstants { public FlowInfo initsOnFinally; // only used within try blocks; remembers upstream flow info mergedWith // any null related operation happening within the try block - /** + /** * Used to record whether effects in a try block affect the finally-block * conditionally or unconditionally. * -1 means: no effect, @@ -95,7 +95,7 @@ public class FlowContext implements TypeConstants { // inside an assertFalse or a not-expression checks for equality / inequality have reversed meaning for syntactic analysis for fields: public static final int INSIDE_NEGATION = 0x4; /** - * used to hide null comparison related warnings inside assert statements + * used to hide null comparison related warnings inside assert statements */ public static final int HIDE_NULL_COMPARISON_WARNING = 0x1000; public static final int HIDE_NULL_COMPARISON_WARNING_MASK = 0xF000; @@ -107,7 +107,7 @@ public static final int CAN_ONLY_NULL = 0x0001; public static final int CAN_ONLY_NON_NULL = 0x0002; //check against non null, with definite values -- comparisons public static final int MAY_NULL = 0x0003; -//check binding a value to a @NonNull variable +//check binding a value to a @NonNull variable public final static int ASSIGN_TO_NONNULL = 0x0080; //check against an unboxing conversion public static final int IN_UNBOXING = 0x0010; @@ -186,10 +186,10 @@ public void extendTimeToLiveForNullCheckedField(int t) { /** * Forget any information about fields that were previously known to be non-null. - * + * * Will only cause any effect if CompilerOptions.enableSyntacticNullAnalysisForFields * (implicitly by guards before calls to {@link #recordNullCheckedFieldReference(Reference, int)}). - */ + */ public void expireNullCheckedFieldInfo() { if (this.nullCheckedFieldReferences != null) { for (int i = 0; i < this.nullCheckedFieldReferences.length; i++) { @@ -199,7 +199,7 @@ public void expireNullCheckedFieldInfo() { } } -/** +/** * Is the given field reference equivalent to a reference that is freshly known to be non-null? * Can only return true if CompilerOptions.enableSyntacticNullAnalysisForFields * (implicitly by guards before calls to {@link #recordNullCheckedFieldReference(Reference, int)}). @@ -243,7 +243,7 @@ public void checkExceptionHandlers(TypeBinding raisedException, ASTNode location if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7 && location instanceof ThrowStatement) { Expression throwExpression = ((ThrowStatement)location).exception; LocalVariableBinding throwArgBinding = throwExpression.localVariableBinding(); - if (throwExpression instanceof SingleNameReference // https://bugs.eclipse.org/bugs/show_bug.cgi?id=350361 + if (throwExpression instanceof SingleNameReference // https://bugs.eclipse.org/bugs/show_bug.cgi?id=350361 && throwArgBinding instanceof CatchParameterBinding && throwArgBinding.isEffectivelyFinal()) { CatchParameterBinding parameter = (CatchParameterBinding) throwArgBinding; checkExceptionHandlers(parameter.getPreciseTypes(), location, flowInfo, scope); @@ -431,7 +431,7 @@ public void checkExceptionHandlers(TypeBinding[] raisedExceptions, ASTNode locat caughtException, exceptionFlow.unconditionalInits(), raisedException, - caughtException, + caughtException, location, false); // was not caught already per construction @@ -655,16 +655,16 @@ public FlowContext getTargetContextForDefaultContinue() { return null; } -/** +/** * Answer flow context that corresponds to initialization. Suitably override in subtypes. */ public FlowContext getInitializationContext() { return null; } -/** +/** * Answer the parent flow context but be careful not to cross the boundary of a nested type, - * or null if no such parent exists. + * or null if no such parent exists. */ public FlowContext getLocalParent() { if (this.associatedNode instanceof AbstractMethodDeclaration || this.associatedNode instanceof TypeDeclaration || this.associatedNode instanceof LambdaExpression) @@ -770,7 +770,7 @@ public void recordContinueFrom(FlowContext innerFlowContext, FlowInfo flowInfo) // default implementation: do nothing } -/** +/** * Record that we found an early exit from a method while a resource is in scope. * @param scope enclosing scope * @param flowInfo flowInfo at the point of the early exit @@ -912,7 +912,7 @@ public void recordSettingFinal(VariableBinding variable, Reference finalReferenc * CAN_ONLY_NULL_NON_NULL}, {@link #MAY_NULL MAY_NULL}, potentially * combined with a context indicator (one of {@link #IN_COMPARISON_NULL}, * {@link #IN_COMPARISON_NON_NULL}, {@link #IN_ASSIGNMENT} or {@link #IN_INSTANCEOF}) - * and a bit to indicate whether the reference is being recorded inside an assert, + * and a bit to indicate whether the reference is being recorded inside an assert, * {@link #HIDE_NULL_COMPARISON_WARNING} * @param flowInfo the flow info at the check point; deferring contexts will * perform supplementary checks against flow info instances that cannot diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java index 6c1e05594..fd144cd4d 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java @@ -12,7 +12,7 @@ * IBM Corporation - initial API and implementation * Fraunhofer FIRST - extended API and implementation * Technical University Berlin - extended API and implementation - * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contributions for + * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contributions for * bug 292478 - Report potentially null across variable assignment * bug 332637 - Dead Code detection removing code that isn't dead * bug 394768 - [compiler][resource] Incorrect resource leak warning when creating stream in conditional @@ -40,9 +40,9 @@ public abstract class FlowInfo { public int tagBits; // REACHABLE by default public final static int REACHABLE = 0; - /* unreachable code + /* unreachable code * eg. while (true); - * i++; --> unreachable code + * i++; --> unreachable code */ public final static int UNREACHABLE_OR_DEAD = 1; /* unreachable code as inferred by null analysis @@ -57,7 +57,7 @@ public abstract class FlowInfo { */ public final static int UNREACHABLE = UNREACHABLE_OR_DEAD | UNREACHABLE_BY_NULLANALYSIS; public final static int NULL_FLAG_MASK = 4; - + public final static int UNKNOWN = 1; public final static int NULL = 2; public final static int NON_NULL = 4; @@ -66,7 +66,7 @@ public abstract class FlowInfo { public final static int POTENTIALLY_NON_NULL = 32; public final static int UNROOTED = 64; // marks a flowInfo that may be appended to another flowInfo (accepting incoming nulls/nonnulls, see UFI.iNBit/iNNBit). - + public static final int FREE_TYPEVARIABLE = FlowInfo.POTENTIALLY_NULL | FlowInfo.POTENTIALLY_NON_NULL; public static final UnconditionalFlowInfo DEAD_END; // Represents a dead branch status of initialization @@ -553,7 +553,7 @@ public static UnconditionalFlowInfo mergedOptimizedBranchesIfElse( // if a variable is only initialized in one branch and not initialized in the other, // then we need to cast a doubt on its initialization in the merged info mergedInfo.mergeDefiniteInitsWith(initsWhenFalse.unconditionalCopy()); - + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=415997, classify unreachability precisely, IsElseStatementUnreachable could be due to null analysis if ((mergedInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0 && (initsWhenFalse.tagBits & FlowInfo.UNREACHABLE) == FlowInfo.UNREACHABLE_BY_NULLANALYSIS) { mergedInfo.tagBits &= ~UNREACHABLE_OR_DEAD; @@ -567,7 +567,7 @@ public static UnconditionalFlowInfo mergedOptimizedBranchesIfElse( // true or false (i.e if(true), etc) for sure // We don't do this if both if and else branches themselves are in an unreachable code // or if any of them is a DEAD_END (e.g. contains 'return' or 'throws') - mergedInfo = + mergedInfo = initsWhenFalse.addPotentialInitializationsFrom(initsWhenTrue. nullInfoLessUnconditionalCopy()). unconditionalInits(); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java index 2f516b0bd..5d2f44002 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -58,7 +58,7 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext { public FlowContext getInitializationContext() { return this; } - + @Override public String individualToString() { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java index 203f56866..f8af4898f 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Stephan Herrmann - contributions for @@ -276,7 +276,7 @@ public void complainOnDeferredNullChecks(BlockScope scope, FlowInfo callerFlowIn } break; } - } + } break; case MAY_NULL: if (flowInfo.isDefinitelyNull(local)) { @@ -507,7 +507,7 @@ public void recordContinueFrom(FlowContext innerFlowContext, FlowInfo flowInfo) FlowContext inner = innerFlowContext; while (inner != this && !(inner instanceof LoopingFlowContext)) { inner = inner.parent; - // we know that inner is reachable from this without crossing a type boundary + // we know that inner is reachable from this without crossing a type boundary } if (inner == this) { this.upstreamNullFlowInfo. diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/TryFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/TryFlowContext.java index 32d9cee33..4df6bbf86 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/TryFlowContext.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/TryFlowContext.java @@ -30,7 +30,7 @@ public abstract class TryFlowContext extends FlowContext { public TryFlowContext(FlowContext parent, ASTNode associatedNode) { super(parent, associatedNode, true); } - + @Override public void markFinallyNullStatus(LocalVariableBinding local, int nullStatus) { if (this.outerTryContext != null) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java index a78dbb797..4b99fb741 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java @@ -98,7 +98,7 @@ public class UnconditionalFlowInfo extends FlowInfo { 1110 prot. null 1111 prot. non null */ - public long + public long iNBit, // can an incoming null value reach the current point? iNNBit; // can an incoming nonnull value reach the current point? @@ -120,12 +120,12 @@ public class UnconditionalFlowInfo extends FlowInfo { public static final int IN = 6; public static final int INN = 7; -/* fakeInitializedFlowInfo: For Lambda expressions tentative analysis during overload resolution. - We presume that any and all outer locals touched by the lambda are definitely assigned and +/* fakeInitializedFlowInfo: For Lambda expressions tentative analysis during overload resolution. + We presume that any and all outer locals touched by the lambda are definitely assigned and effectively final. Whether they are or not is immaterial for overload analysis (errors encountered - in the body are not supposed to influence the resolution. It is pertinent only for the eventual + in the body are not supposed to influence the resolution. It is pertinent only for the eventual resolution/analysis post overload resolution. For lambda's the problem is that we start the control/data - flow analysis abruptly at the start of the lambda, so we need to present a cogent world view and hence + flow analysis abruptly at the start of the lambda, so we need to present a cogent world view and hence all this charade. */ public static UnconditionalFlowInfo fakeInitializedFlowInfo(int localsCount, int maxFieldCount) { @@ -157,7 +157,7 @@ private FlowInfo addInfoFrom(FlowInfo inits, boolean handleInits) { // union of potentially set ones this.potentialInits |= otherInits.potentialInits; } - + // combine null information boolean thisHadNulls = (this.tagBits & NULL_FLAG_MASK) != 0, otherHasNulls = (otherInits.tagBits & NULL_FLAG_MASK) != 0; @@ -192,7 +192,7 @@ private FlowInfo addInfoFrom(FlowInfo inits, boolean handleInits) { long protNN1111 = a1&a2&a3&a4; // filter 'a' using iNBit,iNNBit from otherInits: - // this implements that otherInit does not accept certain bits which are known to be superseded by info in otherInits. + // this implements that otherInit does not accept certain bits which are known to be superseded by info in otherInits. long acceptNonNull = otherInits.iNNBit; long acceptNull = otherInits.iNBit | protNN1111; // for 1111 don't bother suppressing incoming null, logic operation would produce wrong result @@ -203,7 +203,7 @@ private FlowInfo addInfoFrom(FlowInfo inits, boolean handleInits) { a3 = dontResetToStart & acceptNonNull & a3; a4 &= dontResetToStart; a1 &= (a2 | a3 | a4); // translate 1000 (undefined state) to 0000 - + this.nullBit1 = (b1 = otherInits.nullBit1) | a1 & (a3 & a4 & (nb2 = ~(b2 = otherInits.nullBit2)) @@ -319,7 +319,7 @@ private FlowInfo addInfoFrom(FlowInfo inits, boolean handleInits) { for (; i < copyLimit; i++) { this.extra[0][i] = otherInits.extra[0][i]; this.extra[1][i] = otherInits.extra[1][i]; - + } } // tweak limits for nulls @@ -342,7 +342,7 @@ private FlowInfo addInfoFrom(FlowInfo inits, boolean handleInits) { long protNN1111 = a1&a2&a3&a4; // filter 'a' using iNBit,iNNBit from otherInits: - // this implements that otherInit does not accept certain bits which are known to be superseded by info in otherInits. + // this implements that otherInit does not accept certain bits which are known to be superseded by info in otherInits. long acceptNonNull = otherInits.extra[INN][i]; long acceptNull = otherInits.extra[IN][i] | protNN1111; // for 1111 don't bother suppressing incoming null, logic operation would produce wrong result @@ -355,7 +355,7 @@ private FlowInfo addInfoFrom(FlowInfo inits, boolean handleInits) { a1 &= (a2 | a3 | a4); // translate 1000 (undefined state) to 0000 this.extra[1 + 1][i] = (b1 = otherInits.extra[1 + 1][i]) - | a1 & (a3 + | a1 & (a3 & a4 & (nb2 = ~(b2 = otherInits.extra[2 + 1][i])) & (nb4 = ~(b4 = otherInits.extra[4 + 1][i])) | ((na4 = ~a4) | (na3 = ~a3)) @@ -1818,7 +1818,7 @@ public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) { } else if (thisHadNulls) { if (otherHasNulls) { this.nullBit1 = (a1 = this.nullBit1) & (b1 = otherInits.nullBit1) & ( - ((a2 = this.nullBit2) & (((b2 = otherInits.nullBit2) & + ((a2 = this.nullBit2) & (((b2 = otherInits.nullBit2) & ~(((a3=this.nullBit3) & (a4=this.nullBit4)) ^ ((b3=otherInits.nullBit3) & (b4=otherInits.nullBit4)))) |(a3 & a4 & (nb2 = ~b2)))) |((na2 = ~a2) & ((b2 & b3 & b4) @@ -1962,7 +1962,7 @@ public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) { // compose nulls for (i = 0; i < mergeLimit; i++) { this.extra[1 + 1][i] = (a1=this.extra[1+1][i]) & (b1=otherInits.extra[1+1][i]) & ( - ((a2=this.extra[2+1][i]) & (((b2=otherInits.extra[2+1][i]) & + ((a2=this.extra[2+1][i]) & (((b2=otherInits.extra[2+1][i]) & ~(((a3=this.extra[3+1][i]) & (a4=this.extra[4+1][i])) ^ ((b3=otherInits.extra[3+1][i]) & (b4=otherInits.extra[4+1][i])))) |(a3 & a4 & (nb2=~b2)))) |((na2=~a2) & ((b2 & b3 & b4) @@ -2091,7 +2091,7 @@ public FlowInfo safeInitsWhenTrue() { public FlowInfo setReachMode(int reachMode) { if (this == DEAD_END) {// cannot modify DEAD_END return this; - } + } if (reachMode == REACHABLE ) { this.tagBits &= ~UNREACHABLE; } else if (reachMode == UNREACHABLE_BY_NULLANALYSIS ) { |