Class MethodExecutionInfo

java.lang.Object
proguard.evaluation.executor.MethodExecutionInfo

public class MethodExecutionInfo extends Object
This class stores data relevant to modeling the execution of a method and offers methods to extract additional information.
  • 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 (using ClassReferenceInitializer).
      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

      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 List<Clazz> getParametersClasses()
      Returns the referenced Clazz 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 referenced Clazz 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 String getTargetType()
      Get the static target type of the method. For constructors this corresponds to the type of the constructed object.
    • getReturnType

      public 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 Optional<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 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:
      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).
    • getProgramClassPool

      @NotNull public @NotNull ClassPool getProgramClassPool()
    • getLibraryClassPool

      @NotNull public @NotNull ClassPool getLibraryClassPool()