Package proguard.evaluation.executor
Class MethodExecutionInfo
- java.lang.Object
-
- proguard.evaluation.executor.MethodExecutionInfo
-
public class MethodExecutionInfo extends java.lang.Object
This class stores data relevant to modeling the execution of a method and offers methods to extract additional information.
-
-
Constructor Summary
Constructors Constructor Description MethodExecutionInfo(@NotNull Clazz clazz, @NotNull Method method, @Nullable CodeLocation caller, @NotNull Value... parameters)
Constructs a MethodExecutionInfo.MethodExecutionInfo(ConcreteCall call, Value... parameters)
Constructs a MethodExecutionInfo.MethodExecutionInfo(AnyMethodrefConstant anyMethodrefConstant, CodeLocation caller, Value... parameters)
Constructs a MethodExecutionInfo.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable CodeLocation
getCaller()
Get the code location of the call site.@NotNull ReferenceValue
getInstanceNonStatic()
Returns the calling instance value of the method, throws if the method is static.@Nullable ReferenceValue
getInstanceOrNullIfStatic()
Returns the calling instance value of the method, or null if the method is static.java.util.Optional<java.lang.String>
getInstanceType()
Get the type of the instance, or empty for static methods.java.util.List<Value>
getParameters()
Returns the parameters of the method, calling instance not included.java.util.List<Clazz>
getParametersClasses()
Returns the referencedClazz
for each parameter.MethodSignature
getResolvedTargetSignature()
Gets the resolved target of the method call.@Nullable Clazz
getReturnClass()
Get the return class of the method.java.lang.String
getReturnType()
Get the static return type of the method.MethodSignature
getSignature()
Get the method signature of the method@NotNull IdentifiedReferenceValue
getSpecificInstance()
Returns the specific calling instance value of the method.@NotNull Clazz
getTargetClass()
Returns the referencedClazz
of the target method.@NotNull java.lang.String
getTargetType()
Get the static target type of the method.boolean
isConstructor()
Return whether the method is a constructor.boolean
isInstanceMethod()
boolean
isStatic()
Return whether the method is static.boolean
returnsSameTypeAsInstance()
Return whether the return and instance types of the method match.boolean
returnsVoid()
Whether the method returns void.void
setResolvedTargetSignature(@NotNull MethodSignature resolvedTargetSignature)
Sets the lazy property containing the resolved target of the method calls.
-
-
-
Constructor Detail
-
MethodExecutionInfo
public MethodExecutionInfo(@NotNull @NotNull Clazz clazz, @NotNull @NotNull Method method, @Nullable @Nullable CodeLocation caller, @NotNull @NotNull Value... parameters)
Constructs a MethodExecutionInfo.- Parameters:
clazz
- The referenced class.method
- The referenced method.caller
- The code location of the call site. May be null.parameters
- The parameters of the call, calling instance included.
-
MethodExecutionInfo
public MethodExecutionInfo(AnyMethodrefConstant anyMethodrefConstant, CodeLocation caller, Value... parameters)
Constructs a MethodExecutionInfo.- Parameters:
anyMethodrefConstant
- A method reference constant. Requires referenced class to be initialized (usingClassReferenceInitializer
).caller
- The code location of the call site. May be null.parameters
- The parameters of the call, calling instance included.
-
MethodExecutionInfo
public MethodExecutionInfo(ConcreteCall call, Value... parameters)
Constructs a MethodExecutionInfo.- Parameters:
call
- the concrete call.parameters
- The parameters of the call, calling instance included.
-
-
Method Detail
-
getSignature
public MethodSignature getSignature()
Get the method signature of the method
-
getCaller
@Nullable public @Nullable CodeLocation getCaller()
Get the code location of the call site. Might not be provided depending on if the analysis needs it or not
-
isConstructor
public boolean isConstructor()
Return whether the method is a constructor.
-
isStatic
public boolean isStatic()
Return whether the method is static.
-
isInstanceMethod
public boolean isInstanceMethod()
-
getReturnClass
@Nullable public @Nullable Clazz getReturnClass()
Get the return class of the method.This is the return class as declared in the invoked method descriptor, method execution might provide a more specific runtime type.
- Returns:
- The return referenced class. Can be null if the class pools have not been initialized; even if they have, the clazz not being null is not a guarantee.
-
getParametersClasses
public java.util.List<Clazz> getParametersClasses()
Returns the referencedClazz
for each parameter.- Returns:
- The referenced class for each parameter (instance excluded), where each parameter can be accessed given its position (starting from 0, category 2 values take only one slot). An element is null if the corresponding parameter is of a primitive type or an array of primitives. An element can be null if the class pools have not been initialized; even if they have, elements not being null is not a guarantee
-
getTargetClass
@NotNull public @NotNull Clazz getTargetClass()
Returns the referencedClazz
of the target method. Corresponds to the invocation instance class for instance methods and constructor calls.- Returns:
- The target referenced class. Can't be null since this is a condition for the execution to be possible.
-
getTargetType
@NotNull public @NotNull java.lang.String getTargetType()
Get the static target type of the method. For constructors this corresponds to the type of the constructed object.
-
getReturnType
public java.lang.String getReturnType()
Get the static return type of the method.This is the return type as declared in the invoked method constructor, method execution might provide a more specific runtime type.
-
getInstanceType
public java.util.Optional<java.lang.String> getInstanceType()
Get the type of the instance, or empty for static methods.
-
returnsSameTypeAsInstance
public boolean returnsSameTypeAsInstance()
Return whether the return and instance types of the method match.
-
returnsVoid
public boolean returnsVoid()
Whether the method returns void.
-
getInstanceNonStatic
@NotNull public @NotNull ReferenceValue getInstanceNonStatic()
Returns the calling instance value of the method, throws if the method is static.
-
getSpecificInstance
@NotNull public @NotNull IdentifiedReferenceValue getSpecificInstance()
Returns the specific calling instance value of the method. Should only be called if the instance is known to be present and specific, will throw otherwise.
-
getInstanceOrNullIfStatic
@Nullable public @Nullable ReferenceValue getInstanceOrNullIfStatic()
Returns the calling instance value of the method, or null if the method is static.
-
getParameters
public java.util.List<Value> getParameters()
Returns the parameters of the method, calling instance not included.
-
getResolvedTargetSignature
public MethodSignature getResolvedTargetSignature()
Gets the resolved target of the method call. For constructors and static methods this corresponds to the static signature, while dynamic method resolution is performed by the invocation unit for instance methods (i.e., the class in the signature is the calculated runtime type of the instance).This property is lazily initialized and is guaranteed to be available while
Executor.getMethodResult(MethodExecutionInfo, ValueCalculator)
is running.- Throws:
java.lang.IllegalStateException
- if called before the initialization of the property.
-
setResolvedTargetSignature
public void setResolvedTargetSignature(@NotNull @NotNull MethodSignature resolvedTargetSignature)
Sets the lazy property containing the resolved target of the method calls. For constructors and static methods this corresponds to the static signature, while dynamic method resolution is performed by the invocation unit for instance methods (i.e., the class in the signature is the calculated runtime type of the instance).
-
-