Class JavaConstant.MethodType

    • Field Detail

      • returnType

        private final TypeDescription returnType
        The return type of this method type.
      • parameterTypes

        private final java.util.List<? extends TypeDescription> parameterTypes
        The parameter types of this method type.
    • Constructor Detail

      • MethodType

        protected MethodType​(TypeDescription returnType,
                             java.util.List<? extends TypeDescription> parameterTypes)
        Creates a method type for the given types.
        Parameters:
        returnType - The return type of the method type.
        parameterTypes - The parameter types of the method type.
    • Method Detail

      • doPrivileged

        @Enhance
        private static <T> T doPrivileged​(java.security.PrivilegedAction<T> action)
        A proxy for java.security.AccessController#doPrivileged that is activated if available.
        Type Parameters:
        T - The type of the action's resolved value.
        Parameters:
        action - The action to execute from a privileged context.
        Returns:
        The action's resolved value.
      • ofAsm

        public static JavaConstant.MethodType ofAsm​(TypePool typePool,
                                                    org.objectweb.asm.Type methodType)
        Resolves an ASM Type of sort Type.METHOD.
        Parameters:
        typePool - The type pool to resolve type descriptions with.
        methodType - The ASM method Type to resolve.
        Returns:
        An appropriate JavaConstant.MethodType.
      • ofLoaded

        public static JavaConstant.MethodType ofLoaded​(java.lang.Object methodType)
        Returns a method type representation of a loaded MethodType object.
        Parameters:
        methodType - A method type object to represent as a JavaConstant.
        Returns:
        The method type represented as a JavaConstant.MethodType.
      • of

        public static JavaConstant.MethodType of​(java.lang.Class<?> returnType,
                                                 java.lang.Class<?>... parameterType)
        Returns a method type description of the given return type and parameter types.
        Parameters:
        returnType - The return type to represent.
        parameterType - The parameter types to represent.
        Returns:
        A method type of the given return type and parameter types.
      • of

        public static JavaConstant.MethodType of​(TypeDescription returnType,
                                                 TypeDescription... parameterType)
        Returns a method type description of the given return type and parameter types.
        Parameters:
        returnType - The return type to represent.
        parameterType - The parameter types to represent.
        Returns:
        A method type of the given return type and parameter types.
      • of

        public static JavaConstant.MethodType of​(TypeDescription returnType,
                                                 java.util.List<? extends TypeDescription> parameterTypes)
        Returns a method type description of the given return type and parameter types.
        Parameters:
        returnType - The return type to represent.
        parameterTypes - The parameter types to represent.
        Returns:
        A method type of the given return type and parameter types.
      • of

        public static JavaConstant.MethodType of​(java.lang.reflect.Method method)
        Returns a method type description of the given method.
        Parameters:
        method - The method to extract the method type from.
        Returns:
        The method type of the given method.
      • of

        public static JavaConstant.MethodType of​(java.lang.reflect.Constructor<?> constructor)
        Returns a method type description of the given constructor.
        Parameters:
        constructor - The constructor to extract the method type from.
        Returns:
        The method type of the given constructor.
      • of

        public static JavaConstant.MethodType of​(MethodDescription methodDescription)
        Returns a method type description of the given method.
        Parameters:
        methodDescription - The method to extract the method type from.
        Returns:
        The method type of the given method.
      • ofSignature

        public static JavaConstant.MethodType ofSignature​(java.lang.reflect.Method method)
        Returns a method type description of the given method's signature without considering the method's actual stack consumption and production.
        Parameters:
        method - The method to extract the method type from.
        Returns:
        The method type of the given method's signature.
      • ofSignature

        public static JavaConstant.MethodType ofSignature​(java.lang.reflect.Constructor<?> constructor)
        Returns a method type description of the given constructor's signature without considering the constructor's actual stack consumption and production.
        Parameters:
        constructor - The constructor to extract the method type from.
        Returns:
        The method type of the given method's signature.
      • ofSignature

        public static JavaConstant.MethodType ofSignature​(MethodDescription methodDescription)
        Returns a method type description of the given method's signature without considering the method's actual stack consumption and production.
        Parameters:
        methodDescription - The method to extract the method type from.
        Returns:
        The method type of the given method's signature.
      • ofSetter

        public static JavaConstant.MethodType ofSetter​(java.lang.reflect.Field field)
        Returns a method type for a setter of the given field.
        Parameters:
        field - The field to extract a setter type for.
        Returns:
        The type of a setter for the given field.
      • ofSetter

        public static JavaConstant.MethodType ofSetter​(FieldDescription fieldDescription)
        Returns a method type for a setter of the given field.
        Parameters:
        fieldDescription - The field to extract a setter type for.
        Returns:
        The type of a setter for the given field.
      • ofGetter

        public static JavaConstant.MethodType ofGetter​(java.lang.reflect.Field field)
        Returns a method type for a getter of the given field.
        Parameters:
        field - The field to extract a getter type for.
        Returns:
        The type of a getter for the given field.
      • ofGetter

        public static JavaConstant.MethodType ofGetter​(FieldDescription fieldDescription)
        Returns a method type for a getter of the given field.
        Parameters:
        fieldDescription - The field to extract a getter type for.
        Returns:
        The type of a getter for the given field.
      • ofConstant

        public static JavaConstant.MethodType ofConstant​(java.lang.Object instance)
        Returns a method type for the given constant.
        Parameters:
        instance - The constant for which a constant method type should be created.
        Returns:
        A method type for the given constant.
      • ofConstant

        public static JavaConstant.MethodType ofConstant​(java.lang.Class<?> type)
        Returns a method type for the given constant type.
        Parameters:
        type - The constant type for which a constant method type should be created.
        Returns:
        A method type for the given constant type.
      • ofConstant

        public static JavaConstant.MethodType ofConstant​(TypeDescription typeDescription)
        Returns a method type for the given constant type.
        Parameters:
        typeDescription - The constant type for which a constant method type should be created.
        Returns:
        A method type for the given constant type.
      • getReturnType

        public TypeDescription getReturnType()
        Returns the return type of this method type.
        Returns:
        The return type of this method type.
      • getParameterTypes

        public TypeList getParameterTypes()
        Returns the parameter types of this method type.
        Returns:
        The parameter types of this method type.
      • getDescriptor

        public java.lang.String getDescriptor()
        Returns the method descriptor of this method type representation.
        Returns:
        The method descriptor of this method type representation.
      • toDescription

        public java.lang.Object toDescription()
        Returns this constant as a Java java.lang.constant.ConstantDesc if the current VM is of at least version 12. If the current VM is of an older version and does not support the type, an exception is thrown.
        Specified by:
        toDescription in interface JavaConstant
        Returns:
        This constant as a Java java.lang.constant.ConstantDesc.
      • accept

        public <T> T accept​(JavaConstant.Visitor<T> visitor)
        Applies the supplied visitor to this constant type with its respective callback.
        Specified by:
        accept in interface JavaConstant
        Type Parameters:
        T - The type of the value that is returned by the visitor.
        Parameters:
        visitor - The visitor to dispatch.
        Returns:
        The value that is returned by the supplied visitor.
      • getTypeDescription

        public TypeDescription getTypeDescription()
        Returns a description of the type of this constant.
        Specified by:
        getTypeDescription in interface ConstantValue
        Returns:
        A description of the type of this constant.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(@MaybeNull
                              java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object