Class FlowInfo
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowInfo
- Direct Known Subclasses:
ConditionalFlowInfo
,UnconditionalFlowInfo
-
Field Summary
Modifier and TypeFieldDescriptionstatic final UnconditionalFlowInfo
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract FlowInfo
addInitializationsFrom
(FlowInfo otherInits) Add other inits to this flow info, then return this.abstract FlowInfo
addNullInfoFrom
(FlowInfo otherInits) Add all null information from otherInits to this flow info and return this.abstract FlowInfo
addPotentialInitializationsFrom
(FlowInfo otherInits) Compose other inits over this flow info, then return this.boolean
Check whether a given local variable is known to be unable to gain a definite non null or definite null status by the use of an enclosing flow info.boolean
cannotBeNull
(LocalVariableBinding local) Check whether a given local variable is known to be non null, either because it is definitely non null, or because is has been tested against non null.boolean
Check whether a given local variable is known to be null, either because it is definitely null, or because is has been tested against null.static FlowInfo
conditional
(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse) abstract FlowInfo
copy()
Return a deep copy of the current instance.abstract boolean
Check if any null info has been recorded for a given local variable.static UnconditionalFlowInfo
initial
(int maxFieldCount) abstract FlowInfo
Return the flow info that would result from the path associated to the value false for the condition expression that generated this flow info.abstract FlowInfo
Return the flow info that would result from the path associated to the value true for the condition expression that generated this flow info.abstract boolean
isDefinitelyAssigned
(FieldBinding field) Check status of definite assignment for a field.abstract boolean
Check status of definite assignment for a local.abstract boolean
Check status of definite non-null value for a given local variable.abstract boolean
Check status of definite null value for a given local variable.abstract boolean
Check status of definite unknown value for a given local variable.abstract boolean
Check status of potential assignment for a field.abstract boolean
Check status of potential assignment for a local variable.abstract boolean
Check status of potential null assignment for a local.abstract boolean
Check status of potential null assignment for a local.abstract boolean
Return true if the given local may have been assigned to an unknown value.abstract boolean
Return true if the given local is protected by a test against a non null value.abstract boolean
Return true if the given local is protected by a test against null.abstract void
Record that a local variable got checked to be non null.abstract void
Record that a local variable got checked to be null.abstract void
Record a field got definitely assigned.abstract void
Record a local got definitely assigned.abstract void
Record a local got definitely assigned to a non-null value.abstract void
Record a local got definitely assigned to null.abstract void
Record a local got definitely assigned to an unknown value.void
markNullStatus
(LocalVariableBinding local, int nullStatus) Mark the null status of the given local according to the given statusabstract void
Record a local may have got assigned to non-null (set the bit on existing info).abstract void
Record a local may have got assigned to null (set the bit on existing info).abstract void
Record a local may have got assigned to unknown (set the bit on existing info).abstract UnconditionalFlowInfo
mergeDefiniteInitsWith
(UnconditionalFlowInfo otherInits) static UnconditionalFlowInfo
mergedOptimizedBranches
(FlowInfo initsWhenTrue, boolean isOptimizedTrue, FlowInfo initsWhenFalse, boolean isOptimizedFalse, boolean allowFakeDeadBranch) Merge branches using optimized boolean conditionsstatic UnconditionalFlowInfo
mergedOptimizedBranchesIfElse
(FlowInfo initsWhenTrue, boolean isOptimizedTrue, FlowInfo initsWhenFalse, boolean isOptimizedFalse, boolean allowFakeDeadBranch, FlowInfo flowInfo, IfStatement ifStatement, boolean reportDeadCodeInKnownPattern) Merge if-else branches using optimized boolean conditionsabstract UnconditionalFlowInfo
mergedWith
(UnconditionalFlowInfo otherInits) Return the intersection of this and otherInits, that is one of: the receiver updated in the following way: intersection of definitely assigned variables, union of potentially assigned variables, similar operations for null, or the receiver or otherInits if the other one is non reachable. otherInits is not affected, and is not returned either (no need to protect the result).static int
mergeNullStatus
(int nullStatus1, int nullStatus2) Merge two single bits (NULL, NON_NULL, POTENTIALLY*..) into one.abstract UnconditionalFlowInfo
Return a copy of this unconditional flow info, deprived from its null info.int
nullStatus
(LocalVariableBinding local) Answer the null status of the given localint
Find out the reachability mode of this flowInfo.abstract void
Resets the definite and potential initialization info for the given local variableabstract void
Reset all null-information about a given local.abstract FlowInfo
Return a flow info that carries the same information as the result ofinitsWhenTrue
, but warrantied to be different from this.
Caveat: side effects on the result may affect components of this.abstract FlowInfo
setReachMode
(int reachMode) Set this flow info reach mode and return this.static int
tagBitsToNullStatus
(long tagBits) Check whether 'tagBits' contains eitherTagBits.AnnotationNonNull
orTagBits.AnnotationNullable
, and answer the corresponding null status (NON_NULL
etc.).toString()
abstract UnconditionalFlowInfo
Return a new flow info that holds the same information as this would after a call to unconditionalInits, but leaving this info unaffected.abstract UnconditionalFlowInfo
Return a new flow info that holds the same information as this would after a call tounconditionalInits
followed by the erasure of fields specific information, but leaving this flow info unaffected.abstract UnconditionalFlowInfo
Return a flow info that merges the possible paths of execution described by this flow info.abstract UnconditionalFlowInfo
Return a new flow info that holds the same information as this would after a call tounconditionalInits
, but leaving this info unaffected.
-
Field Details
-
tagBits
public int tagBits -
REACHABLE
public static final int REACHABLE- See Also:
-
UNREACHABLE_OR_DEAD
public static final int UNREACHABLE_OR_DEAD- See Also:
-
UNREACHABLE_BY_NULLANALYSIS
public static final int UNREACHABLE_BY_NULLANALYSIS- See Also:
-
UNREACHABLE
public static final int UNREACHABLE- See Also:
-
NULL_FLAG_MASK
public static final int NULL_FLAG_MASK- See Also:
-
UNKNOWN
public static final int UNKNOWN- See Also:
-
NULL
public static final int NULL- See Also:
-
NON_NULL
public static final int NON_NULL- See Also:
-
POTENTIALLY_UNKNOWN
public static final int POTENTIALLY_UNKNOWN- See Also:
-
POTENTIALLY_NULL
public static final int POTENTIALLY_NULL- See Also:
-
POTENTIALLY_NON_NULL
public static final int POTENTIALLY_NON_NULL- See Also:
-
UNROOTED
public static final int UNROOTED- See Also:
-
FREE_TYPEVARIABLE
public static final int FREE_TYPEVARIABLE- See Also:
-
DEAD_END
-
-
Constructor Details
-
FlowInfo
public FlowInfo()
-
-
Method Details
-
addInitializationsFrom
Add other inits to this flow info, then return this. The operation semantics are to match as closely as possible the application to this flow info of all the operations that resulted into otherInits.- Parameters:
otherInits
- other inits to add to this- Returns:
- this, modified according to otherInits information
-
addNullInfoFrom
Add all null information from otherInits to this flow info and return this. The operation models the effect of an unconditional sequence of this flow info and otherInits. -
addPotentialInitializationsFrom
Compose other inits over this flow info, then return this. The operation semantics are to wave into this flow info the consequences of a possible path into the operations that resulted into otherInits. The fact that this path may be left unexecuted under peculiar conditions results into less specific results thanaddInitializationsFrom
.- Parameters:
otherInits
- other inits to compose over this- Returns:
- this, modified according to otherInits information
-
asNegatedCondition
-
conditional
-
cannotBeDefinitelyNullOrNonNull
Check whether a given local variable is known to be unable to gain a definite non null or definite null status by the use of an enclosing flow info. The semantics are that if the current flow info marks the variable as potentially unknown or else as being both potentially null and potentially non null, then it won't ever be promoted as definitely null or definitely non null. (It could still get promoted to definite unknown).- Parameters:
local
- the variable to check- Returns:
- true iff this flow info prevents local from being promoted to definite non null or definite null against an enclosing flow info
-
cannotBeNull
Check whether a given local variable is known to be non null, either because it is definitely non null, or because is has been tested against non null.- Parameters:
local
- the variable to ckeck- Returns:
- true iff local cannot be null for this flow info
-
canOnlyBeNull
Check whether a given local variable is known to be null, either because it is definitely null, or because is has been tested against null.- Parameters:
local
- the variable to ckeck- Returns:
- true iff local can only be null for this flow info
-
copy
Return a deep copy of the current instance.- Returns:
- a deep copy of this flow info
-
initial
-
initsWhenFalse
Return the flow info that would result from the path associated to the value false for the condition expression that generated this flow info. May be this flow info if it is not an instance ofConditionalFlowInfo
. May have a side effect on subparts of this flow info (subtrees get merged).- Returns:
- the flow info associated to the false branch of the condition that generated this flow info
-
initsWhenTrue
Return the flow info that would result from the path associated to the value true for the condition expression that generated this flow info. May be this flow info if it is not an instance ofConditionalFlowInfo
. May have a side effect on subparts of this flow info (subtrees get merged).- Returns:
- the flow info associated to the true branch of the condition that generated this flow info
-
isDefinitelyAssigned
Check status of definite assignment for a field. -
isDefinitelyAssigned
Check status of definite assignment for a local. -
isDefinitelyNonNull
Check status of definite non-null value for a given local variable.- Parameters:
local
- the variable to ckeck- Returns:
- true iff local is definitely non null for this flow info
-
isDefinitelyNull
Check status of definite null value for a given local variable.- Parameters:
local
- the variable to ckeck- Returns:
- true iff local is definitely null for this flow info
-
isDefinitelyUnknown
Check status of definite unknown value for a given local variable.- Parameters:
local
- the variable to ckeck- Returns:
- true iff local is definitely unknown for this flow info
-
hasNullInfoFor
Check if any null info has been recorded for a given local variable. Here even recording of 'UNKNOWN' is considered as null info. -
isPotentiallyAssigned
Check status of potential assignment for a field. -
isPotentiallyAssigned
Check status of potential assignment for a local variable. -
isPotentiallyNonNull
Check status of potential null assignment for a local. Return true if there is a reasonable expectation that the variable be non null at this point.- Parameters:
local
- LocalVariableBinding - the binding for the checked local- Returns:
- true if there is a reasonable expectation that local be non null at this point
-
isPotentiallyNull
Check status of potential null assignment for a local. Return true if there is a reasonable expectation that the variable be null at this point. This includes the protected null case, so as to augment diagnostics, but does not really check that someone deliberately assigned to null on any specific path- Parameters:
local
- LocalVariableBinding - the binding for the checked local- Returns:
- true if there is a reasonable expectation that local be null at this point
-
isPotentiallyUnknown
Return true if the given local may have been assigned to an unknown value.- Parameters:
local
- the local to check- Returns:
- true if the given local may have been assigned to an unknown value
-
isProtectedNonNull
Return true if the given local is protected by a test against a non null value.- Parameters:
local
- the local to check- Returns:
- true if the given local is protected by a test against a non null
-
isProtectedNull
Return true if the given local is protected by a test against null.- Parameters:
local
- the local to check- Returns:
- true if the given local is protected by a test against null
-
markAsComparedEqualToNonNull
Record that a local variable got checked to be non null.- Parameters:
local
- the checked local variable
-
markAsComparedEqualToNull
Record that a local variable got checked to be null.- Parameters:
local
- the checked local variable
-
markAsDefinitelyAssigned
Record a field got definitely assigned. -
markAsDefinitelyNonNull
Record a local got definitely assigned to a non-null value. -
markAsDefinitelyNull
Record a local got definitely assigned to null. -
resetNullInfo
Reset all null-information about a given local. -
markPotentiallyUnknownBit
Record a local may have got assigned to unknown (set the bit on existing info). -
markPotentiallyNullBit
Record a local may have got assigned to null (set the bit on existing info). -
markPotentiallyNonNullBit
Record a local may have got assigned to non-null (set the bit on existing info). -
markAsDefinitelyAssigned
Record a local got definitely assigned. -
markAsDefinitelyUnknown
Record a local got definitely assigned to an unknown value. -
markNullStatus
Mark the null status of the given local according to the given status- Parameters:
nullStatus
- bitset of FLowInfo.UNKNOWN ... FlowInfo.POTENTIALLY_NON_NULL
-
nullStatus
Answer the null status of the given local- Returns:
- bitset of FlowInfo.UNKNOWN ... FlowInfo.POTENTIALLY_NON_NULL
-
mergeNullStatus
public static int mergeNullStatus(int nullStatus1, int nullStatus2) Merge two single bits (NULL, NON_NULL, POTENTIALLY*..) into one. This method implements a simpler logic than the 4-bit encoding used in FlowInfo instances. -
mergedOptimizedBranches
public static UnconditionalFlowInfo mergedOptimizedBranches(FlowInfo initsWhenTrue, boolean isOptimizedTrue, FlowInfo initsWhenFalse, boolean isOptimizedFalse, boolean allowFakeDeadBranch) Merge branches using optimized boolean conditions -
mergedOptimizedBranchesIfElse
public static UnconditionalFlowInfo mergedOptimizedBranchesIfElse(FlowInfo initsWhenTrue, boolean isOptimizedTrue, FlowInfo initsWhenFalse, boolean isOptimizedFalse, boolean allowFakeDeadBranch, FlowInfo flowInfo, IfStatement ifStatement, boolean reportDeadCodeInKnownPattern) Merge if-else branches using optimized boolean conditions -
reachMode
public int reachMode()Find out the reachability mode of this flowInfo.- Returns:
- REACHABLE if this flow info is reachable, otherwise either UNREACHABLE_OR_DEAD or UNREACHABLE_BY_NULLANALYSIS.
-
safeInitsWhenTrue
Return a flow info that carries the same information as the result ofinitsWhenTrue
, but warrantied to be different from this.
Caveat: side effects on the result may affect components of this.- Returns:
- the result of initsWhenTrue or a copy of it
-
setReachMode
Set this flow info reach mode and return this.- Parameters:
reachMode
- one ofREACHABLE
,UNREACHABLE_OR_DEAD
,UNREACHABLE_BY_NULLANALYSIS
orUNREACHABLE
- Returns:
- this, with the reach mode set to reachMode
-
mergedWith
Return the intersection of this and otherInits, that is one of:- the receiver updated in the following way:
- intersection of definitely assigned variables,
- union of potentially assigned variables,
- similar operations for null,
- or the receiver or otherInits if the other one is non reachable.
- Parameters:
otherInits
- the flow info to merge with this- Returns:
- the intersection of this and otherInits.
- the receiver updated in the following way:
-
mergeDefiniteInitsWith
-
nullInfoLessUnconditionalCopy
Return a copy of this unconditional flow info, deprived from its null info.DEAD_END
is returned unmodified.- Returns:
- a copy of this unconditional flow info deprived from its null info
-
toString
-
unconditionalCopy
Return a new flow info that holds the same information as this would after a call to unconditionalInits, but leaving this info unaffected. Moreover, the result can be modified without affecting this.- Returns:
- a new flow info carrying this unconditional flow info
-
unconditionalFieldLessCopy
Return a new flow info that holds the same information as this would after a call tounconditionalInits
followed by the erasure of fields specific information, but leaving this flow info unaffected.- Returns:
- a new flow info carrying the unconditional flow info for local variables
-
unconditionalInits
Return a flow info that merges the possible paths of execution described by this flow info. In case of an unconditional flow info, return this. In case of a conditional flow info, merge branches recursively. Caveat: this may be affected, and modifying the result may affect this.- Returns:
- a flow info that merges the possible paths of execution described by this
-
unconditionalInitsWithoutSideEffect
Return a new flow info that holds the same information as this would after a call tounconditionalInits
, but leaving this info unaffected. Side effects on the result might affect this though (consider it as read only).- Returns:
- a flow info carrying this unconditional flow info
-
resetAssignmentInfo
Resets the definite and potential initialization info for the given local variable -
tagBitsToNullStatus
public static int tagBitsToNullStatus(long tagBits) Check whether 'tagBits' contains eitherTagBits.AnnotationNonNull
orTagBits.AnnotationNullable
, and answer the corresponding null status (NON_NULL
etc.).
-