Class RecordedInvocation

java.lang.Object
org.springframework.aot.agent.RecordedInvocation

public final class RecordedInvocation extends Object
Record of an invocation of a method relevant to RuntimeHints.

The RuntimeHintsAgent instruments bytecode and intercepts invocations of specific methods; invocations are recorded during test execution to match them against an existing RuntimeHints configuration.

Since:
6.0
Author:
Brian Clozel
  • Method Details

    • of

      public static RecordedInvocation.Builder of(org.springframework.aot.agent.InstrumentedMethod instrumentedMethod)
      Initialize a builder for the given InstrumentedMethod.
      Parameters:
      instrumentedMethod - the instrumented method
      Returns:
      a builder
    • getHintType

      public HintType getHintType()
      Return the category of RuntimeHints this invocation relates to.
      Returns:
      the hint type
    • getMethodReference

      public MethodReference getMethodReference()
      Return a simple representation of the method invoked here.
      Returns:
      the method reference
    • getStackFrames

      public Stream<StackWalker.StackFrame> getStackFrames()
      Return the stack trace of the current invocation.
      Returns:
      the stack frames
    • getInstance

      public <T> T getInstance()
      Return the instance of the object being invoked.
      Returns:
      the object instance
      Throws:
      IllegalStateException - in case of static invocations (there is no this)
    • getInstanceTypeReference

      public TypeReference getInstanceTypeReference()
      Return the Type reference of the object being invoked.
      Returns:
      the instance type reference, or null
      Throws:
      IllegalStateException - in case of static invocations (there is no this)
    • isStatic

      public boolean isStatic()
      Return whether the current invocation is static.
      Returns:
      true if the invocation is static
    • getArguments

      public List<Object> getArguments()
      Return the argument values used for the current reflection invocation.
      Returns:
      the invocation arguments
    • getArgument

      public <T> T getArgument(int index)
      Return the argument value at the given index used for the current reflection invocation.
      Parameters:
      index - the parameter index
      Returns:
      the argument at the given index
    • getArgumentTypes

      public List<TypeReference> getArgumentTypes()
      Return the types of the arguments used for the current reflection invocation.
      Returns:
      the argument types
    • getArgumentTypes

      public List<TypeReference> getArgumentTypes(int index)
      Return the types of the arguments used for the current reflection invocation, starting from the given index.
      Returns:
      the argument types, starting at the given index
    • getReturnValue

      @Nullable public <T> T getReturnValue()
      Return the value actually returned by the invoked method.
      Returns:
      the value returned by the invocation
    • matches

      public boolean matches(RuntimeHints hints)
      Whether the given hints cover the current invocation.

      If the given hint doesn't match this invocation might fail at execution time depending on the target runtime.

      Returns:
      whether the given hints match
    • toString

      public String toString()
      Overrides:
      toString in class Object