Class MethodInvokeUtils

java.lang.Object
com.offbynull.coroutines.instrumenter.asm.MethodInvokeUtils

public final class MethodInvokeUtils extends Object
Utility class to help with handling invocation instructions.
  • Constructor Details

    • MethodInvokeUtils

      private MethodInvokeUtils()
  • Method Details

    • getArgumentCountRequiredForInvocation

      public static int getArgumentCountRequiredForInvocation(org.objectweb.asm.tree.AbstractInsnNode invokeNode)
      Get the number of arguments required for an invocation of some method. This includes the 'this' argument for non-static methods.

      NOTE THAT THIS IS NOT THE NUMBER OF ITEMS ON THE STACK. If the method takes in doubles or longs, each double or long encountered would be 2 items on the stack. This method returns the number of arguments required for the method to be invoked, not the number of items required to be on the stack for the method to be invoked.

      Parameters:
      invokeNode - the invocation instruction (either normal invocation or invokedynamic)
      Returns:
      number of arguments required by this method
      Throws:
      NullPointerException - if any argument is null
      IllegalArgumentException - if invokeNode is neither of type MethodInsnNode nor InvokeDynamicInsnNode, or if type of invocation (MethodInsnNode) cannot be determined
    • getReturnTypeOfInvocation

      public static org.objectweb.asm.Type getReturnTypeOfInvocation(org.objectweb.asm.tree.AbstractInsnNode invokeNode)
      Get the return type of the method being invoked.
      Parameters:
      invokeNode - the invocation instruction (either normal invocation or invokedynamic)
      Returns:
      number of items required on the stack for this method
      Throws:
      NullPointerException - if any argument is null
      IllegalArgumentException - if invokeNode is neither of type MethodInsnNode nor InvokeDynamicInsnNode, or if type of invocation (MethodInsnNode) cannot be determined