|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode
org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement
org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration
org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration
org.aspectj.org.eclipse.jdt.internal.compiler.ast.FakedTrackingVariable
public class FakedTrackingVariable
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
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InvocationSite |
|---|
InvocationSite.EmptyWithAstNode |
| Nested classes/interfaces inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeConstants |
|---|
TypeConstants.CloseMethodRecord |
| Field Summary | |
|---|---|
FakedTrackingVariable |
innerTracker
|
LocalVariableBinding |
originalBinding
|
FakedTrackingVariable |
outerTracker
|
static boolean |
TEST_372319
|
| Fields inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration |
|---|
binding |
| Fields inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration |
|---|
annotations, declarationEnd, declarationSourceEnd, declarationSourceStart, ENUM_CONSTANT, FIELD, hiddenVariableDepth, initialization, INITIALIZER, LOCAL_VARIABLE, modifiers, modifiersSourceStart, name, PARAMETER, type, TYPE_PARAMETER |
| Fields inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement |
|---|
COMPLAINED_FAKE_REACHABLE, COMPLAINED_UNREACHABLE, NOT_COMPLAINED |
| Constructor Summary | |
|---|---|
FakedTrackingVariable(LocalVariableBinding original,
ASTNode location,
FlowInfo flowInfo,
FlowContext flowContext,
int nullStatus)
|
|
| Method Summary | |
|---|---|
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. |
static void |
cleanUpAfterAssignment(BlockScope currentScope,
int lhsBits,
Expression expression)
|
int |
findMostSpecificStatus(FlowInfo flowInfo,
BlockScope currentScope,
BlockScope locationScope)
|
void |
generateCode(BlockScope currentScope,
CodeStream codeStream)
Code generation for a local declaration: i.e. normal assignment to a local variable + unused variable handling |
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. |
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. |
boolean |
hasDefinitelyNoResource(FlowInfo flowInfo)
Answer true if we know for sure that no resource is bound to this variable at the point of 'flowInfo'. |
static boolean |
isAnyCloseable(TypeBinding typeBinding)
Answer wither the given type binding is a subtype of java.lang.AutoCloseable. |
boolean |
isClosedInFinallyOfEnclosing(BlockScope scope)
|
boolean |
isResourceBeingReturned(FakedTrackingVariable returnedResource)
If current is the same as 'returnedResource' or a wrapper thereof, mark as reported and return true, otherwise false. |
void |
markClose(FlowInfo flowInfo,
FlowContext flowContext)
Mark that this resource is closed locally. |
void |
markClosedInNestedMethod()
Mark that this resource is closed from a nested method (inside a local class). |
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. |
int |
mergeCloseStatus(BlockScope currentScope,
int status,
LocalVariableBinding local,
BlockScope outerScope)
|
java.lang.String |
nameForReporting(ASTNode location,
ReferenceContext referenceContext)
|
static FakedTrackingVariable |
pickVarForReporting(java.util.Set varsOfScope,
BlockScope scope,
boolean atExit)
Pick tracking variables from 'varsOfScope' to establish a proper order of processing: As much as possible pick wrapper resources before their inner resources. |
static void |
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. |
void |
recordErrorLocation(ASTNode location,
int nullStatus)
|
int |
reportError(ProblemReporter problemReporter,
ASTNode location,
int nullStatus)
|
void |
reportExplicitClosing(ProblemReporter problemReporter)
|
boolean |
reportRecordedErrors(Scope scope,
int mergedStatus)
|
void |
resetReportingBits()
|
void |
resolve(BlockScope scope)
|
| Methods inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration |
|---|
analyseCode, checkModifiers, getAllAnnotationContexts, getAllAnnotationContexts, getKind, isArgument, isReceiver, traverse |
| Methods inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration |
|---|
freshInferenceContext, genericTypeArguments, isSuperAccess, isTypeAccess, printAsExpression, printStatement, setActualReceiverType, setDepth, setFieldIndex |
| Methods inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement |
|---|
analyseArguments, branchChainTo, checkAgainstNullTypeAnnotation, complainIfUnreachable, expectedType, findConstructorBinding, generateArguments, getExpressionContext, invocationTargetType, isBoxingCompatible, isEmptyBlock, isKnowDeadCodePattern, isValidJavaStatement, print, recordExceptionsForEnclosingLambda, resolveCase |
| Methods inherited from class org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode |
|---|
checkInvocationArguments, concreteStatement, copySE8AnnotationsToType, isFieldUseDeprecated, isImplicitThis, isMethodUseDeprecated, isSuper, isThis, isTypeUseDeprecated, isUnqualifiedSuper, printAnnotations, printIndent, printModifiers, receiverIsImplicitThis, resolveAnnotations, resolveAnnotations, resolveAnnotations, resolveDeprecatedAnnotations, resolvePolyExpressionArguments, resolvePolyExpressionArguments, sourceEnd, sourceStart, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InvocationSite |
|---|
getExpressionContext, invocationTargetType, receiverIsImplicitThis, sourceEnd, sourceStart |
| Field Detail |
|---|
public static boolean TEST_372319
public LocalVariableBinding originalBinding
public FakedTrackingVariable innerTracker
public FakedTrackingVariable outerTracker
| Constructor Detail |
|---|
public FakedTrackingVariable(LocalVariableBinding original,
ASTNode location,
FlowInfo flowInfo,
FlowContext flowContext,
int nullStatus)
| Method Detail |
|---|
public void generateCode(BlockScope currentScope,
CodeStream codeStream)
LocalDeclaration
generateCode in class LocalDeclarationpublic void resolve(BlockScope scope)
resolve in class LocalDeclaration
public static FakedTrackingVariable getCloseTrackingVariable(Expression expression,
FlowInfo flowInfo,
FlowContext flowContext)
expression -
FakedTrackingVariable or null.
public static void preConnectTrackerAcrossAssignment(ASTNode location,
LocalVariableBinding local,
Expression rhs,
FlowInfo flowInfo)
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.
location - the assignment/local declaration being analyzedlocal - the local variable being assigned torhs - 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.
public static void analyseCloseableAllocation(BlockScope scope,
FlowInfo flowInfo,
AllocationExpression allocation)
public static void handleResourceAssignment(BlockScope scope,
FlowInfo upstreamInfo,
FlowInfo flowInfo,
FlowContext flowContext,
ASTNode location,
Expression rhs,
LocalVariableBinding local)
scope - scope containing the assignmentupstreamInfo - info without analysis of the rhs, use this to determine the status of a resource being disconnectedflowInfo - info with analysis of the rhs, use this for recording resource status because this will be passed downstreamflowContext - location - where to report warnigs/errors againstrhs - 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
public static void cleanUpAfterAssignment(BlockScope currentScope,
int lhsBits,
Expression expression)
public static boolean isAnyCloseable(TypeBinding typeBinding)
public int findMostSpecificStatus(FlowInfo flowInfo,
BlockScope currentScope,
BlockScope locationScope)
public int mergeCloseStatus(BlockScope currentScope,
int status,
LocalVariableBinding local,
BlockScope outerScope)
public void markClose(FlowInfo flowInfo,
FlowContext flowContext)
public void markClosedInNestedMethod()
public static FlowInfo markPassedToOutside(BlockScope scope,
Expression expression,
FlowInfo flowInfo,
FlowContext flowContext,
boolean owned)
owned - should the resource be considered owned by some outside?
public static FakedTrackingVariable pickVarForReporting(java.util.Set varsOfScope,
BlockScope scope,
boolean atExit)
public boolean hasDefinitelyNoResource(FlowInfo flowInfo)
public boolean isClosedInFinallyOfEnclosing(BlockScope scope)
public boolean isResourceBeingReturned(FakedTrackingVariable returnedResource)
public void recordErrorLocation(ASTNode location,
int nullStatus)
public boolean reportRecordedErrors(Scope scope,
int mergedStatus)
public int reportError(ProblemReporter problemReporter,
ASTNode location,
int nullStatus)
public void reportExplicitClosing(ProblemReporter problemReporter)
public void resetReportingBits()
public java.lang.String nameForReporting(ASTNode location,
ReferenceContext referenceContext)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||