Class DescriptorFactory


  • public class DescriptorFactory
    extends java.lang.Object
    Factory for creating ClassDescriptors, MethodDescriptors, and FieldDescriptors.
    Author:
    David Hovemeyer
    • Method Detail

      • canonicalizeString

        public static java.lang.String canonicalizeString​(@CheckForNull
                                                          java.lang.String s)
      • instance

        public static DescriptorFactory instance()
        Get the singleton instance of the DescriptorFactory.
        Returns:
        the singleton instance of the DescriptorFactory
      • clearInstance

        public static void clearInstance()
      • getAllClassDescriptors

        public java.util.Collection<ClassDescriptor> getAllClassDescriptors()
      • purge

        public void purge​(java.util.Collection<ClassDescriptor> unusable)
      • getClassDescriptor

        @Nonnull
        public ClassDescriptor getClassDescriptor​(java.lang.Class<?> actualClass)
      • getClassDescriptor

        @Nonnull
        public ClassDescriptor getClassDescriptor​(@SlashedClassName
                                                  java.lang.String className)
        Get a ClassDescriptor for a class name in VM (slashed) format.
        Parameters:
        className - a class name in VM (slashed) format
        Returns:
        ClassDescriptor for that class
      • getClassDescriptorForDottedClassName

        public ClassDescriptor getClassDescriptorForDottedClassName​(@DottedClassName
                                                                    java.lang.String dottedClassName)
        Get a ClassDescriptor for a class name in dotted format.
        Parameters:
        dottedClassName - a class name in dotted format
        Returns:
        ClassDescriptor for that class
      • getMethodDescriptor

        public MethodDescriptor getMethodDescriptor​(org.apache.bcel.classfile.JavaClass jClass,
                                                    org.apache.bcel.classfile.Method method)
      • getMethodDescriptor

        public MethodDescriptor getMethodDescriptor​(@SlashedClassName
                                                    java.lang.String className,
                                                    java.lang.String name,
                                                    java.lang.String signature,
                                                    boolean isStatic)
        Get a MethodDescriptor.
        Parameters:
        className - name of the class containing the method, in VM format (e.g., "java/lang/String")
        name - name of the method
        signature - signature of the method
        isStatic - true if method is static, false otherwise
        Returns:
        MethodDescriptor
      • profile

        public void profile()
      • getFieldDescriptor

        public FieldDescriptor getFieldDescriptor​(@SlashedClassName
                                                  java.lang.String className,
                                                  java.lang.String name,
                                                  java.lang.String signature,
                                                  boolean isStatic)
        Get a FieldDescriptor.
        Parameters:
        className - the name of the class the field belongs to, in VM format (e.g., "java/lang/String")
        name - the name of the field
        signature - the field signature (type)
        isStatic - true if field is static, false if not
        Returns:
        FieldDescriptor
      • getClassDescriptor

        public static ClassDescriptor getClassDescriptor​(org.apache.bcel.generic.ObjectType type)
        Get a ClassDescriptor for the class described by given ObjectType object.
        Parameters:
        type - an ObjectType
        Returns:
        a ClassDescriptor for the class described by the ObjectType
      • createClassDescriptor

        public static ClassDescriptor createClassDescriptor​(org.apache.bcel.classfile.JavaClass c)
      • createClassDescriptorFromResourceName

        public static ClassDescriptor createClassDescriptorFromResourceName​(java.lang.String resourceName)
        Create a class descriptor from a resource name.
        Parameters:
        resourceName - the resource name
        Returns:
        the class descriptor
      • createClassDescriptorFromFieldSignature

        @CheckForNull
        public static ClassDescriptor createClassDescriptorFromFieldSignature​(java.lang.String signature)
        Create a class descriptor from a field signature
      • isClassResource

        public static boolean isClassResource​(java.lang.String resourceName)
        Determine whether or not the given resource name refers to a class.
        Parameters:
        resourceName - the resource name
        Returns:
        true if the resource is a class, false otherwise
      • createClassDescriptorFromSignature

        public static ClassDescriptor createClassDescriptorFromSignature​(java.lang.String signature)
      • createClassOrObjectDescriptorFromSignature

        public static ClassDescriptor createClassOrObjectDescriptorFromSignature​(java.lang.String signature)
      • createClassDescriptor

        public static ClassDescriptor createClassDescriptor​(java.lang.Class<?> aClass)
      • createClassDescriptor

        public static ClassDescriptor[] createClassDescriptor​(java.lang.String[] classNames)
      • createClassDescriptorFromDottedClassName

        public static ClassDescriptor createClassDescriptorFromDottedClassName​(java.lang.String dottedClassName)