Package proguard.evaluation.executor
Class MethodExecutionInfo
java.lang.Object
proguard.evaluation.executor.MethodExecutionInfo
This class stores data relevant to modeling the execution of a method and offers methods to
extract additional information.
-
Constructor Summary
ConstructorsConstructorDescriptionMethodExecutionInfo(@NotNull ClassPool programClassPool, @NotNull ClassPool libraryClassPool, @NotNull Clazz clazz, @NotNull Method method, @Nullable CodeLocation caller, @NotNull Value... parameters) Constructs a MethodExecutionInfo.MethodExecutionInfo(ClassPool programClassPool, ClassPool libraryClassPool, ConcreteCall call, Value... parameters) Constructs a MethodExecutionInfo.MethodExecutionInfo(ClassPool programClassPool, ClassPool libraryClassPool, AnyMethodrefConstant anyMethodrefConstant, CodeLocation caller, Value... parameters) Constructs a MethodExecutionInfo. -
Method Summary
Modifier and TypeMethodDescription@Nullable CodeLocationGet the code location of the call site.@NotNull ReferenceValueReturns the calling instance value of the method, throws if the method is static.@Nullable ReferenceValueReturns the calling instance value of the method, or null if the method is static.Get the type of the instance, or empty for static methods.@NotNull ClassPoolReturns the parameters of the method, calling instance not included.Returns the referencedClazzfor each parameter.@NotNull ClassPoolGets the resolved target of the method call.@Nullable ClazzGet the return class of the method.Get the static return type of the method.Get the method signature of the method@NotNull IdentifiedReferenceValueReturns the specific calling instance value of the method.@NotNull ClazzReturns the referencedClazzof the target method.@NotNull StringGet the static target type of the method.booleanReturn whether the method is a constructor.booleanbooleanisStatic()Return whether the method is static.booleanReturn whether the return and instance types of the method match.booleanWhether the method returns void.voidsetResolvedTargetSignature(@NotNull MethodSignature resolvedTargetSignature) Sets the lazy property containing the resolved target of the method calls.
-
Constructor Details
-
MethodExecutionInfo
public MethodExecutionInfo(@NotNull @NotNull ClassPool programClassPool, @NotNull @NotNull ClassPool libraryClassPool, @NotNull @NotNull Clazz clazz, @NotNull @NotNull Method method, @Nullable @Nullable CodeLocation caller, @NotNull @NotNull Value... parameters) Constructs a MethodExecutionInfo.- Parameters:
programClassPool- The program class pool.libraryClassPool- The library class pool.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(ClassPool programClassPool, ClassPool libraryClassPool, 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(ClassPool programClassPool, ClassPool libraryClassPool, ConcreteCall call, Value... parameters) Constructs a MethodExecutionInfo.- Parameters:
call- the concrete call.parameters- The parameters of the call, calling instance included.
-
-
Method Details
-
getSignature
Get the method signature of the method -
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
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
Returns the referencedClazzfor 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
Returns the referencedClazzof 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
Get the static target type of the method. For constructors this corresponds to the type of the constructed object. -
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
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
Returns the calling instance value of the method, throws if the method is static. -
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
Returns the calling instance value of the method, or null if the method is static. -
getParameters
Returns the parameters of the method, calling instance not included. -
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:
IllegalStateException- if called before the initialization of the property.
-
setResolvedTargetSignature
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). -
getProgramClassPool
-
getLibraryClassPool
-