code: public static int getArgumentCountRequiredForInvocation(AbstractInsnNode invokeNode) {
          Validate.notNull(invokeNode);
  
          if (invokeNode instanceof MethodInsnNode) {
              MethodInsnNode methodInsnNode = (MethodInsnNode) invokeNode;
              int extra;
              int paramCount;
              
              switch (methodInsnNode.getOpcode()) {
                  case Opcodes.INVOKEVIRTUAL:
                  case Opcodes.INVOKESPECIAL:
                  case Opcodes.INVOKEINTERFACE:
                      extra = 1;
                      break;
                  case Opcodes.INVOKESTATIC:
                      extra = 0;
                      break;
                  default:
                      throw new IllegalArgumentException(); // unknown invocation type? probably badly generated instruction node
              }
              Type methodType = Type.getType(methodInsnNode.desc);
              paramCount = methodType.getArgumentTypes().length;
                      
              return paramCount + extra;
          } else if (invokeNode instanceof InvokeDynamicInsnNode) {
              InvokeDynamicInsnNode invokeDynamicInsnNode = (InvokeDynamicInsnNode) invokeNode;
              int paramCount;
              
              Type methodType = Type.getType(invokeDynamicInsnNode.desc);
              paramCount = methodType.getArgumentTypes().length;
              
              return paramCount;
          } else {
              throw new IllegalArgumentException();
          }
      }
docs: Get the number of arguments required for an invocation of some method. This includes the 'this' argument for non-static methods.
  <p>
  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.
  @param invokeNode the invocation instruction (either normal invocation or invokedynamic)
  @return number of arguments required by this method
  @throws NullPointerException if any argument is {@code null}
  @throws IllegalArgumentException if {@code invokeNode} is neither of type {@link MethodInsnNode} nor {@link InvokeDynamicInsnNode},
  or if type of invocation ({@link MethodInsnNode}) cannot be determined