Klasse FakedTrackingVariable

Alle implementierten Schnittstellen:
InvocationSite, TypeConstants, TypeIds

public class FakedTrackingVariable extends LocalDeclaration
A faked local variable declaration used for keeping track of data flows of a special variable. Certain events will be recorded by changing the null info for this variable. See bug 349326 - [1.7] new warning for missing try-with-resources
  • Felddetails

  • Konstruktordetails

  • Methodendetails

    • generateCode

      public void generateCode(BlockScope currentScope, CodeStream codeStream)
      Beschreibung aus Klasse kopiert: LocalDeclaration
      Code generation for a local declaration: i.e. normal assignment to a local variable + unused variable handling
      Setzt außer Kraft:
      generateCode in Klasse LocalDeclaration
    • resolve

      public void resolve(BlockScope scope)
      Setzt außer Kraft:
      resolve in Klasse LocalDeclaration
    • getCloseTrackingVariable

      public static FakedTrackingVariable getCloseTrackingVariable(Expression expression, FlowInfo flowInfo, FlowContext flowContext)
      If expression resolves to a value of type AutoCloseable answer the variable that tracks closing of that local. Covers two cases:
      • value is a local variable reference, create tracking variable it if needed.
      • value is an allocation expression, return a preliminary tracking variable if set.
      Parameter:
      expression -
      Gibt zurück:
      a new FakedTrackingVariable or null.
    • preConnectTrackerAcrossAssignment

      public static FakedTrackingVariable preConnectTrackerAcrossAssignment(ASTNode location, LocalVariableBinding local, Expression rhs, FlowInfo flowInfo)
      Before analyzing an assignment of this shape: singleName = new Allocation() connect any tracking variable of the LHS with the allocation on the RHS. Also the assignment is temporarily stored in the tracking variable in case we need to report errors because the assignment leaves the old LHS value unclosed. In this case the assignment should be used as the error location.
      Parameter:
      location - the assignment/local declaration being analyzed
      local - the local variable being assigned to
      rhs - the rhs of the assignment resp. the initialization of the local variable declaration. Precondition: client has already checked that the resolved type of this expression is either a closeable type or NULL.
    • analyseCloseableAllocation

      public static void analyseCloseableAllocation(BlockScope scope, FlowInfo flowInfo, AllocationExpression allocation)
      Compute/assign a tracking variable for a freshly allocated closeable value, using information from our white lists. See Bug 358903 - Filter practically unimportant resource leak warnings
    • analyseCloseableAcquisition

      public static FlowInfo analyseCloseableAcquisition(BlockScope scope, FlowInfo flowInfo, MessageSend acquisition)
      Check if a message send acquires a closeable from its receiver, see: Bug 463320 - [compiler][resource] potential "resource leak" problem disappears when local variable inlined
    • handleResourceAssignment

      public static void handleResourceAssignment(BlockScope scope, FlowInfo upstreamInfo, FlowInfo flowInfo, FlowContext flowContext, ASTNode location, Expression rhs, LocalVariableBinding local)
      Given the rhs of an assignment or local declaration has a (Auto)Closeable type (or null), setup for leak analysis now: Create or re-use a tracking variable, and wire and initialize everything.
      Parameter:
      scope - scope containing the assignment
      upstreamInfo - info without analysis of the rhs, use this to determine the status of a resource being disconnected
      flowInfo - info with analysis of the rhs, use this for recording resource status because this will be passed downstream
      flowContext -
      location - where to report warnigs/errors against
      rhs - the right hand side of the assignment, this expression is to be analyzed. The caller has already checked that the rhs is either of a closeable type or null.
      local - the local variable into which the rhs is being assigned
    • cleanUpAfterAssignment

      public static void cleanUpAfterAssignment(BlockScope currentScope, int lhsBits, Expression expression)
    • cleanUpUnassigned

      public static void cleanUpUnassigned(BlockScope scope, ASTNode location, FlowInfo flowInfo)
      Unassigned closeables are not visible beyond their enclosing statement, immediately report Ungültige Eingabe: "&" remove after each statement.
    • isAnyCloseable

      public static boolean isAnyCloseable(TypeBinding typeBinding)
      Answer wither the given type binding is a subtype of java.lang.AutoCloseable.
    • findMostSpecificStatus

      public int findMostSpecificStatus(FlowInfo flowInfo, BlockScope currentScope, BlockScope locationScope)
    • mergeCloseStatus

      public int mergeCloseStatus(BlockScope currentScope, int status, LocalVariableBinding local, BlockScope outerScope)
    • markClose

      public void markClose(FlowInfo flowInfo, FlowContext flowContext)
      Mark that this resource is closed locally.
    • markClosedInNestedMethod

      public void markClosedInNestedMethod()
      Mark that this resource is closed from a nested method (inside a local class).
    • markClosedEffectivelyFinal

      public void markClosedEffectivelyFinal()
      Mark that this resource is closed from a try-with-resource with the tracking variable being effectively final).
    • markPassedToOutside

      public static FlowInfo markPassedToOutside(BlockScope scope, Expression expression, FlowInfo flowInfo, FlowContext flowContext, boolean owned)
      Mark that this resource is passed to some outside code (as argument to a method/ctor call or as a return value from the current method), and thus should be considered as potentially closed.
      Parameter:
      owned - should the resource be considered owned by some outside?
    • markForeachElementVar

      public static void markForeachElementVar(LocalDeclaration local)
    • hasDefinitelyNoResource

      public boolean hasDefinitelyNoResource(FlowInfo flowInfo)
      Answer true if we know for sure that no resource is bound to this variable at the point of 'flowInfo'.
    • isClosedInFinallyOfEnclosing

      public boolean isClosedInFinallyOfEnclosing(BlockScope scope)
    • isResourceBeingReturned

      public boolean isResourceBeingReturned(FakedTrackingVariable returnedResource)
      If current is the same as 'returnedResource' or a wrapper thereof, mark as reported and return true, otherwise false.
    • withdraw

      public void withdraw()
    • recordErrorLocation

      public void recordErrorLocation(ASTNode location, int nullStatus)
    • reportRecordedErrors

      public boolean reportRecordedErrors(Scope scope, int mergedStatus, boolean atDeadEnd)
    • reportError

      public int reportError(ProblemReporter problemReporter, ASTNode location, int nullStatus)
    • reportExplicitClosing

      public void reportExplicitClosing(ProblemReporter problemReporter)
    • nameForReporting

      public String nameForReporting(ASTNode location, ReferenceContext referenceContext)