Class DescriptorFactory

java.lang.Object
edu.umd.cs.findbugs.classfile.DescriptorFactory

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

    • canonicalizeString

      @Deprecated public static String canonicalizeString(@CheckForNull String s)
      Deprecated.
      this hack is needless for modern JVM, at least Java8
      This method was designed to canonicalize String to improve performance, but now GC cost is cheaper than calculation cost in application thread so removing this old optimization makes SpotBugs 16% faster.
      Returns:
      given string instance
    • 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 Collection<ClassDescriptor> getAllClassDescriptors()
    • purge

      public void purge(Collection<ClassDescriptor> unusable)
    • getClassDescriptor

      @Nonnull public ClassDescriptor getClassDescriptor(Class<?> actualClass)
    • getClassDescriptor

      @Nonnull public ClassDescriptor getClassDescriptor(@SlashedClassName 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 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 String className, String name, 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()
    • canonicalize

      public void canonicalize(MethodDescriptor m)
    • canonicalize

      public void canonicalize(FieldDescriptor m)
    • getMethodDescriptor

      public MethodDescriptor getMethodDescriptor(MethodAnnotation ma)
    • getFieldDescriptor

      public FieldDescriptor getFieldDescriptor(@SlashedClassName String className, String name, 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
    • getFieldDescriptor

      public FieldDescriptor getFieldDescriptor(@SlashedClassName String className, org.apache.bcel.classfile.Field ma)
    • getFieldDescriptor

      public FieldDescriptor getFieldDescriptor(FieldAnnotation ma)
    • 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(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(String signature)
      Create a class descriptor from a field signature
    • isClassResource

      public static boolean isClassResource(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
    • isModuleInfo

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

      public static ClassDescriptor createClassDescriptorFromSignature(String signature)
    • createClassOrObjectDescriptorFromSignature

      public static ClassDescriptor createClassOrObjectDescriptorFromSignature(String signature)
    • createClassDescriptor

      public static ClassDescriptor createClassDescriptor(Class<?> aClass)
    • createClassDescriptor

      @Nonnull public static ClassDescriptor createClassDescriptor(@SlashedClassName String className)
    • createClassDescriptor

      public static ClassDescriptor[] createClassDescriptor(String[] classNames)
    • createClassDescriptorFromDottedClassName

      public static ClassDescriptor createClassDescriptorFromDottedClassName(String dottedClassName)