Class JavaExpression
- Direct Known Subclasses:
- ArrayAccess,- ArrayCreation,- BinaryOperation,- ClassName,- FieldAccess,- FormalParameter,- LocalVariable,- MethodCall,- SuperReference,- ThisReference,- UnaryOperation,- Unknown,- ValueLiteral
?:; use
 Unknown for unrepresentable expressions).
 This class's representation is like an AST: subparts are also expressions. For declared names (fields, local variables, and methods), it also contains an Element.
Each subclass represents a different type of expression, such as MethodCall, ArrayAccess, LocalVariable, etc.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract <R,P> R accept(JavaExpressionVisitor<R, P> visitor, P p) Accept method of the visitor pattern.atConstructorInvocation(NewClassTree newClassTree) Viewpoint-adaptsthisto thenewClassTree.atFieldAccess(JavaExpression receiver) Viewpoint-adaptsthisto a field access with receiverreceiver.final JavaExpressionatMethodBody(MethodTree methodTree) Viewpoint-adaptsthisto themethodTreeby converting anyFormalParameterintoLocalVariables.final JavaExpressionatMethodInvocation(MethodInvocationTree methodInvocationTree) Viewpoint-adaptsthisto themethodInvocationTree.final JavaExpressionatMethodInvocation(MethodInvocationNode invocationNode) Viewpoint-adaptsthisto theinvocationNode.abstract <T extends JavaExpression>
 @Nullable TcontainedOfClass(Class<T> clazz) Returns the first subexpression whose class is the given class, or null.Returns the first subexpression whose class isUnknown, or null.booleancontainsModifiableAliasOf(Store<?> store, JavaExpression other) Returns true if and only ifotherappears anywhere in this or an expression appears in this such thatothermight alias this expression, and that expression is modifiable.final booleancontainsOfClass(Class<? extends JavaExpression> clazz) Returns true if some subexpression is of given class.abstract booleanReturns true if and only if this contains a JavaExpression that is syntactically equal toother.final booleanReturns true if some subexpression isUnknown.static ArrayAccessReturns the internal representation (asFieldAccess) of aFieldAccessNode.static JavaExpressionWe ignore operations such as widening and narrowing when computing the internal representation.static JavaExpressionReturns the Java expression for aFieldAccessNode.static JavaExpressionfromTree(ExpressionTree tree) Converts a javacExpressionTreeto a CF JavaExpression.static JavaExpressionfromVariableTree(VariableTree tree) Returns the Java expression corresponding to the given variable treetree.static List<FormalParameter>getFormalParameters(ExecutableElement methodEle) Returns the parameters ofmethodEleasFormalParameters.static JavaExpressionReturns the implicit receiver of ele.static List<JavaExpression>getParametersAsLocalVariables(ExecutableElement methodEle) Returns the parameters ofmethodEleasLocalVariables.static JavaExpressiongetPseudoReceiver(TreePath path, TypeMirror enclosingType) Returns either a new ClassName or ThisReference JavaExpression object for the enclosingType.static JavaExpressiongetReceiver(ExpressionTree accessTree) Returns the receiver of the given invocation.getType()booleanReturns true if some subexpression of this can be assigned to from outside the current method body.abstract booleanisDeterministic(AnnotationProvider provider) Returns true if the expression is deterministic.booleanReturns true if the value this expression stands for can be changed by a method call; equivalently, if the value this expression evaluates to can be changed by a side effect from outside the containing method.booleanDeprecated.booleanDeprecated.static booleanlistContainsSyntacticEqualJavaExpression(List<? extends @Nullable JavaExpression> list, JavaExpression other) Returns true if the given list contains a JavaExpression that is syntactically equal toother.static booleanlistIsDeterministic(List<? extends @Nullable JavaExpression> list, AnnotationProvider provider) Returns true if all the expressions in the list are deterministic.abstract booleanReturns true if and only if the two Java expressions are syntactically identical.static booleansyntacticEqualsList(List<? extends @Nullable JavaExpression> lst1, List<? extends @Nullable JavaExpression> lst2) Returns true if the corresponding list elements satisfysyntacticEquals(org.checkerframework.dataflow.expression.JavaExpression).Format this verbosely, for debugging.
- 
Field Details- 
typeThe type of this expression.
 
- 
- 
Constructor Details- 
JavaExpressionCreate a JavaExpression.- Parameters:
- type- the type of the expression
 
 
- 
- 
Method Details- 
getType
- 
containsOfClassReturns true if some subexpression is of given class.If you want to debug and determine which subexpression is of the given class, use containedOfClass(java.lang.Class<T>).- Parameters:
- clazz- the JavaExpression subclass to search for
- Returns:
- true if some subexpression's class is the given class
 
- 
containedOfClassReturns the first subexpression whose class is the given class, or null.This is intended as a diagnostic aid; most clients will use containsOfClass(java.lang.Class<? extends org.checkerframework.dataflow.expression.JavaExpression>).- Type Parameters:
- T- the type corresponding to- clazz
- Parameters:
- clazz- the JavaExpression subclass to search for
- Returns:
- true if some subexpression whose class is the given class
 
- 
containsUnknownReturns true if some subexpression isUnknown.If you want to debug and determine which subexpression is of the given class, use containedUnknown().- Returns:
- true if some subexpression is Unknown
 
- 
containedUnknownReturns the first subexpression whose class isUnknown, or null.This is intended as a diagnostic aid; most clients will use containsUnknown().- Returns:
- the first subexpression whose class is Unknown, or null
 
- 
isDeterministicReturns true if the expression is deterministic.- Parameters:
- provider- an annotation provider (a type factory)
- Returns:
- true if this expression is deterministic
 
- 
listIsDeterministic@Pure public static boolean listIsDeterministic(List<? extends @Nullable JavaExpression> list, AnnotationProvider provider) Returns true if all the expressions in the list are deterministic.- Parameters:
- list- the list whose elements to test
- provider- an annotation provider (a type factory)
- Returns:
- true if all the expressions in the list are deterministic
 
- 
isUnassignableByOtherCodeDeprecated.Returns true if and only if the value this expression stands for cannot be changed (with respect to ==) by a method call. This is the case for local variables, the self reference, final field accesses whose receiver isisUnassignableByOtherCode(), and operations whose operands are allisUnmodifiableByOtherCode().- Returns:
- true if no subexpression of this can be assigned to from outside the current method body
- See Also:
 
- 
isAssignableByOtherCodeReturns true if some subexpression of this can be assigned to from outside the current method body.This is false for local variables, the self reference, final field accesses whose receiver is isUnassignableByOtherCode(), and operations whose operands are all notisModifiableByOtherCode().- Returns:
- true if some subexpression of this can be assigned to from outside the current method body
- See Also:
 
- 
isUnmodifiableByOtherCodeDeprecated.Returns true if and only if the value this expression stands for cannot be changed by a method call, including changes to any of its fields.Approximately, this returns true if the expression is isUnassignableByOtherCode()and its type is immutable.- Returns:
- true if the value of this expression cannot be changed from outside the current method body
- See Also:
 
- 
isModifiableByOtherCodeReturns true if the value this expression stands for can be changed by a method call; equivalently, if the value this expression evaluates to can be changed by a side effect from outside the containing method.Approximately, this returns true if the expression is isAssignableByOtherCode()or its type is mutable. (Stringis an immutable type.)- Returns:
- true if the value of this expression can be changed from outside the current method body
- See Also:
 
- 
syntacticEqualsReturns true if and only if the two Java expressions are syntactically identical.This exists for use by containsSyntacticEqualJavaExpression(org.checkerframework.dataflow.expression.JavaExpression).- Parameters:
- je- the other Java expression to compare to this one
- Returns:
- true if and only if the two Java expressions are syntactically identical
 
- 
syntacticEqualsList@Pure public static boolean syntacticEqualsList(List<? extends @Nullable JavaExpression> lst1, List<? extends @Nullable JavaExpression> lst2) Returns true if the corresponding list elements satisfysyntacticEquals(org.checkerframework.dataflow.expression.JavaExpression).- Parameters:
- lst1- the first list to compare
- lst2- the second list to compare
- Returns:
- true if the corresponding list elements satisfy syntacticEquals(org.checkerframework.dataflow.expression.JavaExpression)
 
- 
containsSyntacticEqualJavaExpressionReturns true if and only if this contains a JavaExpression that is syntactically equal toother.- Parameters:
- other- the JavaExpression to search for
- Returns:
- true if and only if this contains a JavaExpression that is syntactically equal to
     other
 
- 
listContainsSyntacticEqualJavaExpression@Pure public static boolean listContainsSyntacticEqualJavaExpression(List<? extends @Nullable JavaExpression> list, JavaExpression other) Returns true if the given list contains a JavaExpression that is syntactically equal toother.- Parameters:
- list- the list in which to search for a match
- other- the JavaExpression to search for
- Returns:
- true if and only if the list contains a JavaExpression that is syntactically equal to
     other
 
- 
containsModifiableAliasOfReturns true if and only ifotherappears anywhere in this or an expression appears in this such thatothermight alias this expression, and that expression is modifiable.This is always true, except for cases where the Java type information prevents aliasing and none of the subexpressions can alias 'other'. 
- 
toStringDebugFormat this verbosely, for debugging.- Returns:
- a verbose string representation of this
 
- 
fromNodeFieldAccessReturns the Java expression for aFieldAccessNode. The result may containUnknownas receiver.- Parameters:
- node- the FieldAccessNode to convert to a JavaExpression
- Returns:
- the FieldAccessorClassNamethat corresponds tonode
 
- 
fromArrayAccessReturns the internal representation (asFieldAccess) of aFieldAccessNode. The result may containUnknownas receiver.- Parameters:
- node- the ArrayAccessNode to convert to a JavaExpression
- Returns:
- the internal representation (as FieldAccess) of aFieldAccessNode. Can containUnknownas receiver.
 
- 
fromNodeWe ignore operations such as widening and narrowing when computing the internal representation.- Parameters:
- receiverNode- a node to convert to a JavaExpression
- Returns:
- the internal representation of the given node. Might contain Unknown.
 
- 
fromTreeConverts a javacExpressionTreeto a CF JavaExpression. The result might containUnknown.We ignore operations such as widening and narrowing when computing the JavaExpression. - Parameters:
- tree- a javac tree
- Returns:
- a JavaExpression for the given javac tree
 
- 
fromVariableTreeReturns the Java expression corresponding to the given variable treetree.- Parameters:
- tree- a variable tree
- Returns:
- a JavaExpression for tree
 
- 
getParametersAsLocalVariablesReturns the parameters ofmethodEleasLocalVariables.- Parameters:
- methodEle- the method element
- Returns:
- list of parameters as LocalVariables
 
- 
getFormalParametersReturns the parameters ofmethodEleasFormalParameters.- Parameters:
- methodEle- the method element
- Returns:
- list of parameters as FormalParameters
 
- 
getReceiverReturns the receiver of the given invocation.- Parameters:
- accessTree- a method or constructor invocation
- Returns:
- the receiver of the given invocation
 
- 
getImplicitReceiverReturns the implicit receiver of ele.Returns either a new ClassName or a new ThisReference depending on whether ele is static or not. The passed element must be a field, method, or class. When this returns a ThisReference, its type is the class that declares ele, which is not necessarily the type ofthisat the invocation site.- Parameters:
- ele- a field, method, or class
- Returns:
- either a new ClassName or a new ThisReference depending on whether ele is static or not
 
- 
getPseudoReceiverReturns either a new ClassName or ThisReference JavaExpression object for the enclosingType.The Tree should be an expression or a statement that does not have a receiver or an implicit receiver. For example, a local variable declaration. - Parameters:
- path- a tree path
- enclosingType- type of the enclosing type
- Returns:
- a new ClassNameorThisReferencethat is a JavaExpression object for the enclosingType
 
- 
acceptAccept method of the visitor pattern.- Type Parameters:
- R- result type of the operation
- P- parameter type
- Parameters:
- visitor- the visitor to be applied to this JavaExpression
- p- the parameter for this operation
- Returns:
- the result of visiting this
 
- 
atFieldAccessViewpoint-adaptsthisto a field access with receiverreceiver.- Parameters:
- receiver- receiver of the field access
- Returns:
- viewpoint-adapted version of this
 
- 
atMethodBodyViewpoint-adaptsthisto themethodTreeby converting anyFormalParameterintoLocalVariables.- Parameters:
- methodTree- method declaration tree
- Returns:
- viewpoint-adapted version of this
 
- 
atMethodInvocationViewpoint-adaptsthisto themethodInvocationTree.- Parameters:
- methodInvocationTree- method invocation
- Returns:
- viewpoint-adapted version of this
 
- 
atMethodInvocationViewpoint-adaptsthisto theinvocationNode.- Parameters:
- invocationNode- method invocation
- Returns:
- viewpoint-adapted version of this
 
- 
atConstructorInvocationViewpoint-adaptsthisto thenewClassTree.- Parameters:
- newClassTree- constructor invocation
- Returns:
- viewpoint-adapted version of this
 
 
- 
isAssignableByOtherCode()