Package edu.umd.cs.findbugs.classfile
Class DescriptorFactory
java.lang.Object
edu.umd.cs.findbugs.classfile.DescriptorFactory
Factory for creating ClassDescriptors, MethodDescriptors, and
FieldDescriptors.
- Author:
- David Hovemeyer
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidstatic StringDeprecated.this hack is needless for modern JVM, at least Java8static voidstatic ClassDescriptorcreateClassDescriptor(Class<?> aClass) static ClassDescriptorcreateClassDescriptor(String className) static ClassDescriptor[]createClassDescriptor(String[] classNames) static ClassDescriptorcreateClassDescriptor(org.apache.bcel.classfile.JavaClass c) static ClassDescriptorcreateClassDescriptorFromDottedClassName(String dottedClassName) static ClassDescriptorcreateClassDescriptorFromFieldSignature(String signature) Create a class descriptor from a field signaturestatic ClassDescriptorcreateClassDescriptorFromResourceName(String resourceName) Create a class descriptor from a resource name.static ClassDescriptorcreateClassDescriptorFromSignature(String signature) static ClassDescriptorcreateClassOrObjectDescriptorFromSignature(String signature) getClassDescriptor(Class<?> actualClass) getClassDescriptor(String className) Get a ClassDescriptor for a class name in VM (slashed) format.static ClassDescriptorgetClassDescriptor(org.apache.bcel.generic.ObjectType type) Get a ClassDescriptor for the class described by given ObjectType object.getClassDescriptorForDottedClassName(String dottedClassName) Get a ClassDescriptor for a class name in dotted format.getFieldDescriptor(String className, String name, String signature, boolean isStatic) Get a FieldDescriptor.getFieldDescriptor(String className, org.apache.bcel.classfile.Field ma) getMethodDescriptor(String className, String name, String signature, boolean isStatic) Get a MethodDescriptor.getMethodDescriptor(org.apache.bcel.classfile.JavaClass jClass, org.apache.bcel.classfile.Method method) static DescriptorFactoryinstance()Get the singleton instance of the DescriptorFactory.static booleanisClassResource(String resourceName) Determine whether or not the given resource name refers to a class.static booleanisModuleInfo(String resourceName) Determine whether or not the given resource name refers to a module-info class.voidprofile()voidpurge(Collection<ClassDescriptor> unusable)
-
Method Details
-
canonicalizeString
Deprecated.this hack is needless for modern JVM, at least Java8This 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
Get the singleton instance of the DescriptorFactory.- Returns:
- the singleton instance of the DescriptorFactory
-
clearInstance
public static void clearInstance() -
getAllClassDescriptors
-
purge
-
getClassDescriptor
-
getClassDescriptor
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 methodsignature- signature of the methodisStatic- true if method is static, false otherwise- Returns:
- MethodDescriptor
-
profile
public void profile() -
canonicalize
-
canonicalize
-
getMethodDescriptor
-
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 fieldsignature- 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
-
getClassDescriptor
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
-
createClassDescriptorFromResourceName
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
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
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
-
createClassOrObjectDescriptorFromSignature
-
createClassDescriptor
-
createClassDescriptor
-
createClassDescriptor
-
createClassDescriptorFromDottedClassName
-