Class LoopingFlowContext

All Implemented Interfaces:
TypeConstants

public class LoopingFlowContext extends SwitchFlowContext
Reflects the context of code analysis, keeping track of enclosing try statements, exception handlers, etc...
  • Field Details

  • Constructor Details

  • Method Details

    • complainOnDeferredFinalChecks

      public void complainOnDeferredFinalChecks(BlockScope scope, FlowInfo flowInfo)
      Perform deferred checks relative to final variables duplicate initialization of lack of initialization.
      Parameters:
      scope - the scope to which this context is associated
      flowInfo - the flow info against which checks must be performed
    • complainOnDeferredNullChecks

      public void complainOnDeferredNullChecks(BlockScope scope, FlowInfo callerFlowInfo)
      Perform deferred checks relative to the null status of local variables.
      Parameters:
      scope - the scope to which this context is associated
      callerFlowInfo - the flow info against which checks must be performed
    • complainOnDeferredNullChecks

      public void complainOnDeferredNullChecks(BlockScope scope, FlowInfo callerFlowInfo, boolean updateInitsOnBreak)
    • continueLabel

      public BranchLabel continueLabel()
      Overrides:
      continueLabel in class FlowContext
    • individualToString

      public String individualToString()
      Overrides:
      individualToString in class SwitchFlowContext
    • isContinuable

      public boolean isContinuable()
      Overrides:
      isContinuable in class FlowContext
    • isContinuedTo

      public boolean isContinuedTo()
    • recordBreakTo

      public void recordBreakTo(FlowContext targetContext)
      Overrides:
      recordBreakTo in class FlowContext
    • recordContinueFrom

      public void recordContinueFrom(FlowContext innerFlowContext, FlowInfo flowInfo)
      Overrides:
      recordContinueFrom in class FlowContext
    • recordFinalAssignment

      protected boolean recordFinalAssignment(VariableBinding binding, Reference finalAssignment)
      Overrides:
      recordFinalAssignment in class FlowContext
    • recordNullReferenceWithAnnotationStatus

      protected void recordNullReferenceWithAnnotationStatus(LocalVariableBinding local, ASTNode expression, int checkType, FlowInfo nullInfo, NullAnnotationMatching nullAnnotationStatus)
      Description copied from class: FlowContext
      Record a null reference for use by deferred checks. Only looping or finally contexts really record that information. Other contexts immediately check for unboxing.
      Overrides:
      recordNullReferenceWithAnnotationStatus in class FlowContext
      Parameters:
      local - the local variable involved in the check
      expression - the location triggering the analysis, for normal null dereference this is an expression resolving to 'local', for resource leaks it is an early exit statement.
      checkType - the checkType against which the check must be performed; one of CAN_ONLY_NULL, CAN_ONLY_NULL_NON_NULL, MAY_NULL, CAN_ONLY_NON_NULL, potentially combined with a context indicator (one of FlowContext.IN_COMPARISON_NULL, FlowContext.IN_COMPARISON_NON_NULL, FlowContext.IN_ASSIGNMENT or FlowContext.IN_INSTANCEOF).
      Alternatively, a FlowContext.IN_UNBOXING check can e requested.
      nullInfo - the null flow info observed at this first visit of location.
      nullAnnotationStatus - if null annotations are analysed this may hold more information about the exact kind of problem, can be null
    • recordUnboxing

      public void recordUnboxing(Scope scope, Expression expression, int nullStatus, FlowInfo flowInfo)
      Description copied from class: FlowContext
      Either AST analysis or checking of a child flow context has encountered an unboxing situation. Record this fact for handling at an appropriate point in time.
      Overrides:
      recordUnboxing in class FlowContext
      nullStatus - the status as we know it so far.
    • recordExitAgainstResource

      public boolean recordExitAgainstResource(BlockScope scope, FlowInfo flowInfo, FakedTrackingVariable trackingVar, ASTNode reference)
      Record the fact that we see an early exit (in 'reference') while 'trackingVar' is in scope and may be unclosed.
      Overrides:
      recordExitAgainstResource in class FlowContext
      Parameters:
      scope - enclosing scope
      flowInfo - flowInfo at the point of the early exit
      trackingVar - representation of the resource
      reference - the return or throw statement marking the early exit
      Returns:
      true if the situation has been handled by this flow context.
    • recordUsingNullReference

      public void recordUsingNullReference(Scope scope, LocalVariableBinding local, ASTNode location, int checkType, FlowInfo flowInfo)
      Description copied from class: FlowContext
      Record a null reference for use by deferred checks. Only looping or finally contexts really record that information. The context may emit an error immediately depending on the status of local against flowInfo and its nature (only looping of finally contexts defer part of the checks; nonetheless, contexts that are nested into a looping or a finally context get affected and delegate some checks to their enclosing context).
      Overrides:
      recordUsingNullReference in class FlowContext
      Parameters:
      scope - the scope into which the check is performed
      local - the local variable involved in the check
      location - the location triggering the analysis, for normal null dereference this is an expression resolving to 'local', for resource leaks it is an early exit statement.
      checkType - the status against which the check must be performed; one of CAN_ONLY_NULL, CAN_ONLY_NULL_NON_NULL, MAY_NULL, potentially combined with a context indicator (one of FlowContext.IN_COMPARISON_NULL, FlowContext.IN_COMPARISON_NON_NULL, FlowContext.IN_ASSIGNMENT or FlowContext.IN_INSTANCEOF) and a bit to indicate whether the reference is being recorded inside an assert, FlowContext.HIDE_NULL_COMPARISON_WARNING
      flowInfo - the flow info at the check point; deferring contexts will perform supplementary checks against flow info instances that cannot be known at the time of calling this method (they are influenced by code that follows the current point)
    • simulateThrowAfterLoopBack

      public void simulateThrowAfterLoopBack(FlowInfo flowInfo)
    • recordCatchContextOfEscapingException

      public void recordCatchContextOfEscapingException(ExceptionHandlingFlowContext catchingContext, ReferenceBinding caughtException, FlowInfo exceptionInfo)
    • hasEscapingExceptions

      public boolean hasEscapingExceptions()
    • internalRecordNullityMismatch

      protected boolean internalRecordNullityMismatch(Expression expression, TypeBinding providedType, FlowInfo flowInfo, int nullStatus, NullAnnotationMatching nullAnnotationStatus, TypeBinding expectedType, int checkType)
      Overrides:
      internalRecordNullityMismatch in class FlowContext