Class MethodTypeSignature


  • public final class MethodTypeSignature
    extends HierarchicalTypeSignature
    A method type signature (called "MethodSignature" in the classfile documentation).
    • Field Detail

      • typeParameters

        final java.util.List<TypeParameter> typeParameters
        The method type parameters.
      • parameterTypeSignatures

        private final java.util.List<TypeSignature> parameterTypeSignatures
        The method parameter type signatures.
      • resultType

        private final TypeSignature resultType
        The method result type.
      • receiverTypeAnnotationInfo

        private AnnotationInfoList receiverTypeAnnotationInfo
        Any type annotation(s) on an explicit receiver parameter.
    • Constructor Detail

      • MethodTypeSignature

        private MethodTypeSignature​(java.util.List<TypeParameter> typeParameters,
                                    java.util.List<TypeSignature> paramTypes,
                                    TypeSignature resultType,
                                    java.util.List<ClassRefOrTypeVariableSignature> throwsSignatures)
        Constructor.
        Parameters:
        typeParameters - The type parameters for the method.
        paramTypes - The parameter types for the method.
        resultType - The return type for the method.
        throwsSignatures - The throws signatures for the method.
    • Method Detail

      • getTypeParameters

        public java.util.List<TypeParameter> getTypeParameters()
        Get the type parameters for the method, if this is a generic method.
        Returns:
        The type parameters for the method, if any, otherwise null.
      • getParameterTypeSignatures

        java.util.List<TypeSignature> getParameterTypeSignatures()
        Get the type signatures of the method parameters. N.B. this is non-public, since the types have to be aligned with other parameter metadata. The type of a parameter can be obtained post-alignment from the parameter's MethodParameterInfo object.
        Returns:
        The parameter types for the method, as TypeSignature parsed type objects.
      • getResultType

        public TypeSignature getResultType()
        Get the result type for the method.
        Returns:
        The result type for the method, as a TypeSignature parsed type object.
      • addRecieverTypeAnnotation

        void addRecieverTypeAnnotation​(AnnotationInfo annotationInfo)
        Add a type annotation for an explicit receiver parameter.
        Parameters:
        annotationInfo - the receiver type annotation
      • getReceiverTypeAnnotationInfo

        public AnnotationInfoList getReceiverTypeAnnotationInfo()
        Get type annotations on the explicit receiver parameter, or null if none.
        Returns:
        type annotations on the explicit receiver parameter, or null if none.
      • getClassInfo

        protected ClassInfo getClassInfo()
        Description copied from class: ScanResultObject
        Get the ClassInfo object for the referenced class, or null if the referenced class was not encountered during scanning (i.e. no ClassInfo object was created for the class during scanning). N.B. even if this method returns null, ScanResultObject.loadClass() may be able to load the referenced class by name.
        Overrides:
        getClassInfo in class ScanResultObject
        Returns:
        The ClassInfo object for the referenced class.
      • findReferencedClassNames

        protected void findReferencedClassNames​(java.util.Set<java.lang.String> refdClassNames)
        Get the names of any classes referenced in the type signature.
        Parameters:
        refdClassNames - the referenced class names.
      • findReferencedClassInfo

        protected void findReferencedClassInfo​(java.util.Map<java.lang.String,​ClassInfo> classNameToClassInfo,
                                               java.util.Set<ClassInfo> refdClassInfo,
                                               LogNode log)
        Get ClassInfo objects for any classes referenced in the type descriptor or type signature.
        Overrides:
        findReferencedClassInfo in class ScanResultObject
        Parameters:
        classNameToClassInfo - the map from class name to ClassInfo.
        refdClassInfo - the referenced class info
        log - the log
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toStringInternal

        protected void toStringInternal​(boolean useSimpleNames,
                                        AnnotationInfoList annotationsToExclude,
                                        java.lang.StringBuilder buf)
        Description copied from class: HierarchicalTypeSignature
        Render type signature to string.
        Specified by:
        toStringInternal in class HierarchicalTypeSignature
        Parameters:
        useSimpleNames - whether to use simple names for classes.
        annotationsToExclude - toplevel annotations to exclude, to eliminate duplication (toplevel annotations are both class/field/method annotations and type annotations).
        buf - the StringBuilder to write to.
      • parse

        static MethodTypeSignature parse​(java.lang.String typeDescriptor,
                                         java.lang.String definingClassName)
                                  throws ParseException
        Parse a method signature.
        Parameters:
        typeDescriptor - The type descriptor of the method.
        definingClassName - The name of the defining class (for resolving type variables).
        Returns:
        The parsed method type signature.
        Throws:
        ParseException - If method type signature could not be parsed.