public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, boolean checkString) { // cannot override localVariableBinding because this would project o.m onto o when // analyzing assignments if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) { LocalVariableBinding local = (LocalVariableBinding) this.binding; if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0 && (checkString || local.type.id != TypeIds.T_JavaLangString)) { if ((this.bits & ASTNode.IsNonNull) == 0) { flowContext.recordUsingNullReference(scope, local, this, FlowContext.MAY_NULL, flowInfo); } flowInfo.markAsComparedEqualToNonNull(local); // from thereon it is set if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { flowInfo.markedAsNullOrNonNullInAssertExpression(local); } if (flowContext.initsOnFinally != null) { flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { flowContext.initsOnFinally.markedAsNullOrNonNullInAssertExpression(local); } } } } }
/** Mark that this resource is closed locally. */ public void markClose(FlowInfo flowInfo, FlowContext flowContext) { FakedTrackingVariable current = this; do { flowInfo.markAsDefinitelyNonNull(current.binding); current.globalClosingState |= CLOSE_SEEN; //TODO(stephan): this might be useful, but I could not find a test case for it: if (flowContext.initsOnFinally != null) flowContext.initsOnFinally.markAsDefinitelyNonNull(this.binding); current = current.innerTracker; } while (current != null); }
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially non-null' mark in unexpected state"); //$NON-NLS-1$ this.nullBit3 |= mask; if (COVERAGE_TEST_FLAG) { isTrue((this.extra[2][vectorIndex] & mask) == 0, "Adding 'potentially non-null' mark in unexpected state"); //$NON-NLS-1$ this.extra[4][vectorIndex] |= mask; if (COVERAGE_TEST_FLAG) {
flowInfo.unconditionalInits()); handlingContext.initsOnFinally = new NullInfoRegistry(flowInfo.unconditionalInits()); if (this.caughtExceptionTypes[i].isUncheckedException(true)) { catchInfo = handlingContext.initsOnFinally.mitigateNullInfoOf( flowInfo.unconditionalCopy(). addPotentialInitializationsFrom( flowContext.initsOnFinally.add(handlingContext.initsOnFinally); flowInfo.unconditionalInits()); handlingContext.initsOnFinally = new NullInfoRegistry(flowInfo.unconditionalInits()); if (this.caughtExceptionTypes[i].isUncheckedException(true)) { catchInfo = handlingContext.initsOnFinally.mitigateNullInfoOf( flowInfo.unconditionalCopy(). addPotentialInitializationsFrom( handlingContext.initsOnFinally.mitigateNullInfoOf( (tryInfo.tagBits & FlowInfo.UNREACHABLE) == 0 ? flowInfo.unconditionalCopy(). flowContext.initsOnFinally.add(handlingContext.initsOnFinally);
switch(nullStatus) { case FlowInfo.NULL : flowContext.initsOnFinally.markAsDefinitelyNull(local); break; case FlowInfo.NON_NULL : flowContext.initsOnFinally.markAsDefinitelyNonNull(local); break; default: flowContext.initsOnFinally.markAsDefinitelyUnknown(local);
public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, boolean checkString) { // cannot override localVariableBinding because this would project o.m onto o when // analyzing assignments if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) { LocalVariableBinding local = (LocalVariableBinding) this.binding; if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0 && (checkString || local.type.id != TypeIds.T_JavaLangString)) { if ((this.bits & ASTNode.IsNonNull) == 0) { flowContext.recordUsingNullReference(scope, local, this, FlowContext.MAY_NULL, flowInfo); } flowInfo.markAsComparedEqualToNonNull(local); // from thereon it is set if (flowContext.initsOnFinally != null) { flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); } } } }
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // record setting a variable: various scenarii are possible, setting an array reference, // a field reference, a blank final field reference, a field of an enclosing instance or // just a local variable. LocalVariableBinding local = this.lhs.localVariableBinding(); if ((this.expression.implicitConversion & TypeIds.UNBOXING) != 0) { this.expression.checkNPE(currentScope, flowContext, flowInfo); } flowInfo = ((Reference) this.lhs) .analyseAssignment(currentScope, flowContext, flowInfo, this, false) .unconditionalInits(); int nullStatus = this.expression.nullStatus(flowInfo); if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) { if (nullStatus == FlowInfo.NULL) { flowContext.recordUsingNullReference(currentScope, local, this.lhs, FlowContext.CAN_ONLY_NULL | FlowContext.IN_ASSIGNMENT, flowInfo); } } nullStatus = checkAgainstNullAnnotation(currentScope, local, nullStatus); if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) { flowInfo.markNullStatus(local, nullStatus); if (flowContext.initsOnFinally != null) flowContext.initsOnFinally.markNullStatus(local, nullStatus); } return flowInfo; }
flowInfo.unconditionalInits()); handlingContext.initsOnFinally = new NullInfoRegistry(flowInfo.unconditionalInits()); if (this.caughtExceptionTypes[i].isUncheckedException(true)) { catchInfo = handlingContext.initsOnFinally.mitigateNullInfoOf( flowInfo.unconditionalCopy(). addPotentialInitializationsFrom( flowContext.initsOnFinally.add(handlingContext.initsOnFinally); flowInfo.unconditionalInits()); handlingContext.initsOnFinally = new NullInfoRegistry(flowInfo.unconditionalInits()); if (this.caughtExceptionTypes[i].isUncheckedException(true)) { catchInfo = handlingContext.initsOnFinally.mitigateNullInfoOf( flowInfo.unconditionalCopy(). addPotentialInitializationsFrom( handlingContext.initsOnFinally.mitigateNullInfoOf( (tryInfo.tagBits & FlowInfo.UNREACHABLE) == 0 ? flowInfo.unconditionalCopy(). flowContext.initsOnFinally.add(handlingContext.initsOnFinally);
public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, boolean checkString) { // cannot override localVariableBinding because this would project o.m onto o when // analysing assignments if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) { LocalVariableBinding local = (LocalVariableBinding) this.binding; if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0 && (checkString || local.type.id != TypeIds.T_JavaLangString)) { if ((this.bits & ASTNode.IsNonNull) == 0) { flowContext.recordUsingNullReference(scope, local, this, FlowContext.MAY_NULL, flowInfo); } flowInfo.markAsComparedEqualToNonNull(local); // from thereon it is set if (flowContext.initsOnFinally != null) { flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); } } } }
flowInfo.markNullStatus(local, nullStatus); if (flowContext.initsOnFinally != null) flowContext.initsOnFinally.markNullStatus(local, nullStatus);
flowInfo.unconditionalInits()); handlingContext.initsOnFinally = new NullInfoRegistry(flowInfo.unconditionalInits()); if (isUncheckedCatchBlock(i)) { catchInfo = handlingContext.initsOnFinally.mitigateNullInfoOf( flowInfo.unconditionalCopy(). addPotentialInitializationsFrom( flowContext.initsOnFinally.add(handlingContext.initsOnFinally); flowInfo.unconditionalInits()); handlingContext.initsOnFinally = new NullInfoRegistry(flowInfo.unconditionalInits()); if (isUncheckedCatchBlock(i)) { catchInfo = handlingContext.initsOnFinally.mitigateNullInfoOf( flowInfo.unconditionalCopy(). addPotentialInitializationsFrom( handlingContext.initsOnFinally.mitigateNullInfoOf( (tryInfo.tagBits & FlowInfo.UNREACHABLE) == 0 ? flowInfo.unconditionalCopy(). flowContext.initsOnFinally.add(handlingContext.initsOnFinally);
/** * Check the local variable of this expression, if any, against potential NPEs * given a flow context and an upstream flow info. If so, report the risk to * the context. Marks the local as checked, which affects the flow info. * @param scope the scope of the analysis * @param flowContext the current flow context * @param flowInfo the upstream flow info; caveat: may get modified */ public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo) { LocalVariableBinding local = localVariableBinding(); if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) { if ((this.bits & ASTNode.IsNonNull) == 0) { flowContext.recordUsingNullReference(scope, local, this, FlowContext.MAY_NULL, flowInfo); } flowInfo.markAsComparedEqualToNonNull(local); // from thereon it is set if (flowContext.initsOnFinally != null) { flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); } } }
/** * Check the local variable of this expression, if any, against potential NPEs * given a flow context and an upstream flow info. If so, report the risk to * the context. Marks the local as checked, which affects the flow info. * @param scope the scope of the analysis * @param flowContext the current flow context * @param flowInfo the upstream flow info; caveat: may get modified */ public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo) { LocalVariableBinding local = localVariableBinding(); if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) { if ((this.bits & ASTNode.IsNonNull) == 0) { flowContext.recordUsingNullReference(scope, local, this, FlowContext.MAY_NULL, flowInfo); } flowInfo.markAsComparedEqualToNonNull(local); // from thereon it is set if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { flowInfo.markedAsNullOrNonNullInAssertExpression(local); } if (flowContext.initsOnFinally != null) { flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { flowContext.initsOnFinally.markedAsNullOrNonNullInAssertExpression(local); } } } }
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // record setting a variable: various scenarii are possible, setting an array reference, // a field reference, a blank final field reference, a field of an enclosing instance or // just a local variable. if (this.resolvedType.id != T_JavaLangString) { this.lhs.checkNPE(currentScope, flowContext, flowInfo); } flowInfo = ((Reference) this.lhs).analyseAssignment(currentScope, flowContext, flowInfo, this, true).unconditionalInits(); if (this.resolvedType.id == T_JavaLangString) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=339250 LocalVariableBinding local = this.lhs.localVariableBinding(); if (local != null) { // compound assignment results in a definitely non null value for String flowInfo.markAsDefinitelyNonNull(local); if (flowContext.initsOnFinally != null) flowContext.initsOnFinally.markAsDefinitelyNonNull(local); } } return flowInfo; }
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially null' mark in unexpected state"); //$NON-NLS-1$ this.nullBit2 |= mask; if (COVERAGE_TEST_FLAG) { isTrue((this.extra[2][vectorIndex] & mask) == 0, "Adding 'potentially null' mark in unexpected state"); //$NON-NLS-1$ if (COVERAGE_TEST_FLAG) { if(CoverageTestId == 41) {
/** * Check the local variable of this expression, if any, against potential NPEs * given a flow context and an upstream flow info. If so, report the risk to * the context. Marks the local as checked, which affects the flow info. * @param scope the scope of the analysis * @param flowContext the current flow context * @param flowInfo the upstream flow info; caveat: may get modified */ public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo) { LocalVariableBinding local = localVariableBinding(); if (local != null && (local.type.tagBits & TagBits.IsBaseType) == 0) { if ((this.bits & ASTNode.IsNonNull) == 0) { flowContext.recordUsingNullReference(scope, local, this, FlowContext.MAY_NULL, flowInfo); } flowInfo.markAsComparedEqualToNonNull(local); // from thereon it is set if (flowContext.initsOnFinally != null) { flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); } } }
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // record setting a variable: various scenarii are possible, setting an array reference, // a field reference, a blank final field reference, a field of an enclosing instance or // just a local variable. if (this.resolvedType.id != T_JavaLangString) { this.lhs.checkNPE(currentScope, flowContext, flowInfo); } flowInfo = ((Reference) this.lhs).analyseAssignment(currentScope, flowContext, flowInfo, this, true).unconditionalInits(); if (this.resolvedType.id == T_JavaLangString) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=339250 LocalVariableBinding local = this.lhs.localVariableBinding(); if (local != null) { // compound assignment results in a definitely non null value for String flowInfo.markAsDefinitelyNonNull(local); if (flowContext.initsOnFinally != null) flowContext.initsOnFinally.markAsDefinitelyNonNull(local); } } return flowInfo; }
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially null' mark in unexpected state"); //$NON-NLS-1$ this.nullBit2 |= mask; if (COVERAGE_TEST_FLAG) { isTrue((this.extra[2][vectorIndex] & mask) == 0, "Adding 'potentially null' mark in unexpected state"); //$NON-NLS-1$ if (COVERAGE_TEST_FLAG) { if(CoverageTestId == 41) {
isTrue((this.nullBit1 & mask) == 0, "Adding 'potentially non-null' mark in unexpected state"); //$NON-NLS-1$ this.nullBit3 |= mask; if (COVERAGE_TEST_FLAG) { isTrue((this.extra[2][vectorIndex] & mask) == 0, "Adding 'potentially non-null' mark in unexpected state"); //$NON-NLS-1$ this.extra[4][vectorIndex] |= mask; if (COVERAGE_TEST_FLAG) {
isTrue((this.nullBit1 & mask) == 0, "Adding 'unknown' mark in unexpected state"); //$NON-NLS-1$ this.nullBit4 |= mask; if (COVERAGE_TEST_FLAG) { isTrue((this.extra[2][vectorIndex] & mask) == 0, "Adding 'unknown' mark in unexpected state"); //$NON-NLS-1$ this.extra[5][vectorIndex] |= mask; if (COVERAGE_TEST_FLAG) {