Record Class InvocationPlan

java.lang.Object
java.lang.Record
io.micronaut.sourcegen.bytecode.core.InvocationPlan
Record Components:
kind - The instruction
ownerDescriptor - The descriptor of the type the instruction names
name - The name of the method
descriptor - The descriptor of the method, returning what its declaration does
ownerInterface - Whether the owner is an interface, as the constant pool entry of the method says
receiver - What happens to the receiver once it is written
receiverCast - The descriptor of the type the receiver is cast to, for InvocationPlan.Receiver.CAST
method - The invoked method, in the scope of the class declaring it
values - The arguments, converted to the parameters of the method
result - The conversion of the result to the type the call requests, if any

@Internal public record InvocationPlan(InvocationPlan.Kind kind, String ownerDescriptor, String name, String descriptor, boolean ownerInterface, InvocationPlan.Receiver receiver, @Nullable String receiverCast, MethodDef method, List<? extends ExpressionDef> values, @Nullable InvocationPlan.ResultConversion result) extends Record
An invocation as both bytecode writers emit it, planned once: the instruction and what it names - the owner, the descriptor with the return type the method declares, whether the owner is an interface - what happens to the receiver, the parameters the arguments are converted to, and the conversion of the result to the type the call requests. A writer only writes the receiver and the arguments, and emits the plan.
Since:
2.3
  • Constructor Details

  • Method Details

    • ofInstance

      public static InvocationPlan ofInstance(ExpressionDef instance, MethodDef method, List<? extends ExpressionDef> values, @Nullable ObjectDef current, @Nullable MethodDef enclosing)
      The call of a method on a value.
      • A method the receiver does not declare - on this or super, of a variable named alone - or one the class being written does not access is resolved where the call is written.
      • A receiver of a type variable is the bound declaring the method, cast to where it is not the erasure.
      • The method is erased in the scope of the class declaring it, whose variables the caller's can shadow.
      • A static method called through a value is invoked statically, the value evaluated and discarded, as javac does.
      • A call on super is dispatched non-virtually against the supertype, which names an interface method for Interface.super.name(); a call on an interface is invokeinterface, even of a default method.
      • A call requesting another type than its method declares invokes the declaration, and converts what it returns, as javac does: a primitive requested of a generic return unboxes the wrapper the call returns.
      Parameters:
      instance - The receiver
      method - The method
      values - The arguments
      current - The definition being written, if any
      enclosing - The method being written, if any
      Returns:
      The plan
    • ofInstance

      public static InvocationPlan ofInstance(ExpressionDef instance, MethodDef method, List<? extends ExpressionDef> values, @Nullable ObjectDef current, @Nullable MethodDef enclosing, EnclosingScope enclosingScope)
      The call of a method on a value, as ofInstance(ExpressionDef, MethodDef, List, ObjectDef, MethodDef) plans it, in the enclosing scope of the class being written.
      Parameters:
      instance - The receiver
      method - The method
      values - The arguments
      current - The definition being written, if any
      enclosing - The method being written, if any
      enclosingScope - The enclosing scope of the class being written
      Returns:
      The plan
      Since:
      2.3
    • ofStatic

      public static InvocationPlan ofStatic(ClassTypeDef owner, MethodDef method, List<? extends ExpressionDef> values, @Nullable ObjectDef current, @Nullable MethodDef enclosing)
      The call of a static method of a class: resolved, erased and converted as a call on a value is, with no receiver.
      Parameters:
      owner - The class declaring the method
      method - The method
      values - The arguments
      current - The definition being written, if any
      enclosing - The method being written, if any
      Returns:
      The plan
    • ofStatic

      public static InvocationPlan ofStatic(ClassTypeDef owner, MethodDef method, List<? extends ExpressionDef> values, @Nullable ObjectDef current, @Nullable MethodDef enclosing, EnclosingScope enclosingScope)
      The call of a static method of a class, as ofStatic(ClassTypeDef, MethodDef, List, ObjectDef, MethodDef) plans it, in the enclosing scope of the class being written.
      Parameters:
      owner - The class declaring the method
      method - The method
      values - The arguments
      current - The definition being written, if any
      enclosing - The method being written, if any
      enclosingScope - The enclosing scope of the class being written
      Returns:
      The plan
      Since:
      2.3
    • ofNewInstance

      public static InvocationPlan ofNewInstance(ExpressionDef.NewInstance newInstance, @Nullable ObjectDef current, @Nullable MethodDef enclosing)
      The constructor new invokes, erased in the scope of the class declaring it; one the class does not declare, of a variable named alone, or one new does not access from the class being written is resolved where the call is written. The writer writes the new and dup the constructor is invoked on.
      Parameters:
      newInstance - The instantiation
      current - The definition being written, if any
      enclosing - The method being written, if any
      Returns:
      The plan
    • ofNewInstance

      public static InvocationPlan ofNewInstance(ExpressionDef.NewInstance newInstance, @Nullable ObjectDef current, @Nullable MethodDef enclosing, EnclosingScope enclosingScope)
      The constructor new invokes, as ofNewInstance(ExpressionDef.NewInstance, ObjectDef, MethodDef) plans it, in the enclosing scope of the class being written.
      Parameters:
      newInstance - The instantiation
      current - The definition being written, if any
      enclosing - The method being written, if any
      enclosingScope - The enclosing scope of the class being written
      Returns:
      The plan
      Since:
      2.3
    • ofSuperConstructor

      public static InvocationPlan ofSuperConstructor(StatementDef.InvokeSuperConstructor invocation, @Nullable ObjectDef current, @Nullable MethodDef enclosing, EnclosingScope enclosingScope)
      The superclass constructor an explicit super(...) invokes, erased in the scope of the superclass; one the class being written does not access by super(...) - a package-private one of another package - is resolved where the call is written. The writer writes the receiver the constructor is invoked on.
      Parameters:
      invocation - The invocation
      current - The definition being written, if any
      enclosing - The method being written, if any
      enclosingScope - The enclosing scope of the class being written
      Returns:
      The plan
    • superTypeOf

      public static ClassTypeDef superTypeOf(VariableDef.Super aSuper, @Nullable ObjectDef current)
      The supertype a super reference resolves against: the one it names, or the definition's own supertype where it is the placeholder TypeDef.SUPER - Enum of an enum, Record of a record, the superclass of a class and Object otherwise.
      Parameters:
      aSuper - The reference
      current - The definition being written, if any
      Returns:
      The supertype
    • parameterTypes

      public List<TypeDef> parameterTypes()
      Returns:
      The types of the parameters the arguments are converted to
    • ownerInternalName

      public String ownerInternalName()
      Returns:
      The internal name of the owner, which is the descriptor of an array type
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • kind

      public InvocationPlan.Kind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • ownerDescriptor

      public String ownerDescriptor()
      Returns the value of the ownerDescriptor record component.
      Returns:
      the value of the ownerDescriptor record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • descriptor

      public String descriptor()
      Returns the value of the descriptor record component.
      Returns:
      the value of the descriptor record component
    • ownerInterface

      public boolean ownerInterface()
      Returns the value of the ownerInterface record component.
      Returns:
      the value of the ownerInterface record component
    • receiver

      public InvocationPlan.Receiver receiver()
      Returns the value of the receiver record component.
      Returns:
      the value of the receiver record component
    • receiverCast

      public @Nullable String receiverCast()
      Returns the value of the receiverCast record component.
      Returns:
      the value of the receiverCast record component
    • method

      public MethodDef method()
      Returns the value of the method record component.
      Returns:
      the value of the method record component
    • values

      public List<? extends ExpressionDef> values()
      Returns the value of the values record component.
      Returns:
      the value of the values record component
    • result

      public @Nullable InvocationPlan.ResultConversion result()
      Returns the value of the result record component.
      Returns:
      the value of the result record component