Interface MethodCreator

All Superinterfaces:
AnnotatedElement, AutoCloseable, BytecodeCreator, MemberCreator<MethodCreator>, SignatureElement<MethodCreator>
All Known Implementing Classes:
ClassTransfromerMethodCreatorImpl, MethodCreatorImpl

A class that builds the body of a method without needing to understand java bytecode.
  • Method Details

    • addException

      MethodCreator addException(String exception)
      Adds an exception to the method signature
      Parameters:
      exception - The exception
      Returns:
      This creator
    • addException

      default MethodCreator addException(Class<?> exception)
      Adds an exception to the method signature
      Parameters:
      exception - The exception
      Returns:
      This creator
    • getExceptions

      List<String> getExceptions()
      Returns:
      The exceptions thrown by this method
    • getMethodDescriptor

      MethodDescriptor getMethodDescriptor()
      Returns:
      The method descriptor
    • getParameterAnnotations

      AnnotatedElement getParameterAnnotations(int param)
    • setParameterNames

      void setParameterNames(String[] parameterNames)
      Sets names of all this method's parameters. The length of parameterNames must be equal to the number of this method's parameters. Removes previously set parameter names if parameterNames is null.

      It is required to set all parameter names in one go, because parameter names are stored in bytecode as a simple sequence, without positions.

      When generating a method with mandated or synthetic parameters (such as an inner class constructor), remember that these parameters must have names too.

      Parameters:
      parameterNames - names of all parameters of this method