public class Hierarchy
extends java.lang.Object
Repository
class. Callers should
generally expect to handle ClassNotFoundException for when referenced classes
can't be found.Modifier and Type | Field and Description |
---|---|
static JavaClassAndMethodChooser |
ANY_METHOD
JavaClassAndMethodChooser which accepts any method.
|
static JavaClassAndMethodChooser |
CONCRETE_METHOD
JavaClassAndMethodChooser which accepts only concrete (not abstract or
native) methods.
|
protected static boolean |
DEBUG_METHOD_LOOKUP |
static ClassDescriptor |
ERROR |
static org.apache.bcel.generic.ObjectType |
ERROR_TYPE
Type of java.lang.Error.
|
static ClassDescriptor |
EXCEPTION |
static org.apache.bcel.generic.ObjectType |
EXCEPTION_TYPE
Type of java.lang.Exception.
|
static JavaClassAndMethodChooser |
INSTANCE_METHOD
JavaClassAndMethodChooser which accepts only instance methods.
|
static ClassDescriptor |
RUNTIME_EXCEPTION |
static org.apache.bcel.generic.ObjectType |
RUNTIME_EXCEPTION_TYPE
Type of java.lang.RuntimeException.
|
static JavaClassAndMethodChooser |
STATIC_METHOD
JavaClassAndMethodChooser which accepts only static methods.
|
Constructor and Description |
---|
Hierarchy() |
Modifier and Type | Method and Description |
---|---|
static boolean |
accessFlagsAreConcrete(int accessFlags) |
static JavaClassAndMethod |
findConcreteMethod(org.apache.bcel.classfile.JavaClass javaClass,
java.lang.String methodName,
java.lang.String methodSig)
Deprecated.
|
static org.apache.bcel.generic.ObjectType[] |
findDeclaredExceptions(org.apache.bcel.generic.InvokeInstruction inv,
org.apache.bcel.generic.ConstantPoolGen cpg)
Deprecated.
|
static JavaClassAndMethod |
findExactMethod(org.apache.bcel.generic.InvokeInstruction inv,
org.apache.bcel.generic.ConstantPoolGen cpg)
Look up the method referenced by given InvokeInstruction.
|
static JavaClassAndMethod |
findExactMethod(org.apache.bcel.generic.InvokeInstruction inv,
org.apache.bcel.generic.ConstantPoolGen cpg,
JavaClassAndMethodChooser chooser)
Look up the method referenced by given InvokeInstruction.
|
static org.apache.bcel.classfile.Field |
findField(java.lang.String className,
java.lang.String fieldName)
Find a field with given name defined in given class.
|
static JavaClassAndMethod |
findInvocationLeastUpperBound(org.apache.bcel.generic.InvokeInstruction inv,
org.apache.bcel.generic.ConstantPoolGen cpg)
Find the least upper bound method in the class hierarchy which could be
called by the given InvokeInstruction.
|
static JavaClassAndMethod |
findInvocationLeastUpperBound(org.apache.bcel.generic.InvokeInstruction inv,
org.apache.bcel.generic.ConstantPoolGen cpg,
JavaClassAndMethodChooser methodChooser) |
static JavaClassAndMethod |
findInvocationLeastUpperBound(org.apache.bcel.classfile.JavaClass jClass,
java.lang.String methodName,
java.lang.String methodSig,
JavaClassAndMethodChooser methodChooser,
boolean invokeInterface) |
static XMethod |
findMethod(ClassDescriptor classDesc,
java.lang.String methodName,
java.lang.String methodSig,
boolean isStatic)
Find a method in given class.
|
static JavaClassAndMethod |
findMethod(org.apache.bcel.classfile.JavaClass[] classList,
java.lang.String methodName,
java.lang.String methodSig)
Deprecated.
|
static JavaClassAndMethod |
findMethod(org.apache.bcel.classfile.JavaClass[] classList,
java.lang.String methodName,
java.lang.String methodSig,
JavaClassAndMethodChooser chooser)
Find a method in given list of classes, searching the classes in order.
|
static JavaClassAndMethod |
findMethod(org.apache.bcel.classfile.JavaClass javaClass,
java.lang.String methodName,
java.lang.String methodSig)
Find a method in given class.
|
static JavaClassAndMethod |
findMethod(org.apache.bcel.classfile.JavaClass javaClass,
java.lang.String methodName,
java.lang.String methodSig,
JavaClassAndMethodChooser chooser) |
static XField |
findXField(org.apache.bcel.generic.FieldInstruction fins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Look up the field referenced by given FieldInstruction, returning it as
an
XField object. |
static XField |
findXField(java.lang.String className,
java.lang.String fieldName,
java.lang.String fieldSig,
boolean isStatic)
Look up a field with given name and signature in given class, returning
it as an
XField object. |
static XMethod |
findXMethod(org.apache.bcel.classfile.JavaClass[] classList,
java.lang.String methodName,
java.lang.String methodSig)
Deprecated.
|
static XMethod |
findXMethod(org.apache.bcel.classfile.JavaClass[] classList,
java.lang.String methodName,
java.lang.String methodSig,
JavaClassAndMethodChooser chooser)
Deprecated.
|
static XMethod |
findXMethod(org.apache.bcel.classfile.JavaClass javaClass,
java.lang.String methodName,
java.lang.String methodSig,
JavaClassAndMethodChooser chooser)
Deprecated.
|
static InnerClassAccess |
getInnerClassAccess(org.apache.bcel.generic.INVOKESTATIC inv,
org.apache.bcel.generic.ConstantPoolGen cpg)
Get the InnerClassAccess for access method called by given INVOKESTATIC.
|
static boolean |
isConcrete(XMethod xmethod)
Deprecated.
|
static boolean |
isInnerClassAccess(org.apache.bcel.generic.INVOKESTATIC inv,
org.apache.bcel.generic.ConstantPoolGen cpg)
Determine whether the given INVOKESTATIC instruction is an inner-class
field accessor method.
|
static boolean |
isMonitorNotify(org.apache.bcel.generic.Instruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Determine if given Instruction is a monitor wait.
|
static boolean |
isMonitorNotify(java.lang.String methodName,
java.lang.String methodSig)
Determine if method whose name and signature is specified is a monitor
notify operation.
|
static boolean |
isMonitorWait(org.apache.bcel.generic.Instruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Determine if given Instruction is a monitor wait.
|
static boolean |
isMonitorWait(java.lang.String methodName,
java.lang.String methodSig)
Determine if method whose name and signature is specified is a monitor
wait operation.
|
static boolean |
isSubtype(org.apache.bcel.generic.ReferenceType t,
org.apache.bcel.generic.ReferenceType possibleSupertype)
Determine if one reference type is a subtype of another.
|
static boolean |
isSubtype(java.lang.String clsName,
java.lang.String possibleSupertypeClassName)
Determine whether one class (or reference type) is a subtype of another.
|
static boolean |
isUncheckedException(org.apache.bcel.generic.ObjectType type)
Determine if the given ObjectType refers to an unchecked exception
(RuntimeException or Error).
|
static boolean |
isUniversalExceptionHandler(org.apache.bcel.generic.ObjectType catchType)
Determine if the given ObjectType reference represents a
universal exception handler.
|
static java.util.Set<JavaClassAndMethod> |
resolveMethodCallTargets(org.apache.bcel.generic.InvokeInstruction invokeInstruction,
TypeFrame typeFrame,
org.apache.bcel.generic.ConstantPoolGen cpg)
Resolve possible method call targets.
|
static java.util.Set<JavaClassAndMethod> |
resolveMethodCallTargets(org.apache.bcel.generic.ReferenceType receiverType,
org.apache.bcel.generic.InvokeInstruction invokeInstruction,
org.apache.bcel.generic.ConstantPoolGen cpg)
Resolve possible instance method call targets.
|
static java.util.Set<JavaClassAndMethod> |
resolveMethodCallTargets(org.apache.bcel.generic.ReferenceType receiverType,
org.apache.bcel.generic.InvokeInstruction invokeInstruction,
org.apache.bcel.generic.ConstantPoolGen cpg,
boolean receiverTypeIsExact)
Resolve possible instance method call targets.
|
static JavaClassAndMethod |
visitSuperClassMethods(JavaClassAndMethod method,
JavaClassAndMethodChooser chooser)
Visit all superclass methods which the given method overrides.
|
static JavaClassAndMethod |
visitSuperInterfaceMethods(JavaClassAndMethod method,
JavaClassAndMethodChooser chooser)
Visit all superinterface methods which the given method implements.
|
protected static final boolean DEBUG_METHOD_LOOKUP
public static final ClassDescriptor RUNTIME_EXCEPTION
public static final ClassDescriptor EXCEPTION
public static final ClassDescriptor ERROR
public static final org.apache.bcel.generic.ObjectType EXCEPTION_TYPE
public static final org.apache.bcel.generic.ObjectType ERROR_TYPE
public static final org.apache.bcel.generic.ObjectType RUNTIME_EXCEPTION_TYPE
public static final JavaClassAndMethodChooser ANY_METHOD
public static final JavaClassAndMethodChooser CONCRETE_METHOD
public static final JavaClassAndMethodChooser STATIC_METHOD
public static final JavaClassAndMethodChooser INSTANCE_METHOD
public static boolean isSubtype(@DottedClassName java.lang.String clsName, @DottedClassName java.lang.String possibleSupertypeClassName) throws java.lang.ClassNotFoundException
clsName
- the name of the class or reference typepossibleSupertypeClassName
- the name of the possible superclassjava.lang.ClassNotFoundException
public static boolean isSubtype(org.apache.bcel.generic.ReferenceType t, org.apache.bcel.generic.ReferenceType possibleSupertype) throws java.lang.ClassNotFoundException
t
- a reference typepossibleSupertype
- the possible supertypejava.lang.ClassNotFoundException
public static boolean isUniversalExceptionHandler(org.apache.bcel.generic.ObjectType catchType)
catchType
- the ObjectType of the exception handlerpublic static boolean isUncheckedException(org.apache.bcel.generic.ObjectType type) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static boolean isMonitorWait(java.lang.String methodName, java.lang.String methodSig)
methodName
- name of the methodmethodSig
- signature of the methodpublic static boolean isMonitorWait(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg)
ins
- the Instructioncpg
- the ConstantPoolGen for the Instructionpublic static boolean isMonitorNotify(java.lang.String methodName, java.lang.String methodSig)
methodName
- name of the methodmethodSig
- signature of the methodpublic static boolean isMonitorNotify(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg)
ins
- the Instructioncpg
- the ConstantPoolGen for the Instructionpublic static JavaClassAndMethod findExactMethod(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg) throws java.lang.ClassNotFoundException
inv
- the InvokeInstructioncpg
- the ConstantPoolGen used by the class the InvokeInstruction
belongs tojava.lang.ClassNotFoundException
public static JavaClassAndMethod findExactMethod(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser chooser) throws java.lang.ClassNotFoundException
inv
- the InvokeInstructioncpg
- the ConstantPoolGen used by the class the InvokeInstruction
belongs tochooser
- JavaClassAndMethodChooser to use to pick the method from among
the candidatesjava.lang.ClassNotFoundException
public static JavaClassAndMethod visitSuperClassMethods(JavaClassAndMethod method, JavaClassAndMethodChooser chooser) throws java.lang.ClassNotFoundException
method
- the methodchooser
- chooser which visits each superclass methodjava.lang.ClassNotFoundException
public static JavaClassAndMethod visitSuperInterfaceMethods(JavaClassAndMethod method, JavaClassAndMethodChooser chooser) throws java.lang.ClassNotFoundException
method
- the methodchooser
- chooser which visits each superinterface methodjava.lang.ClassNotFoundException
@CheckForNull public static JavaClassAndMethod findInvocationLeastUpperBound(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg) throws java.lang.ClassNotFoundException
Find the least upper bound method in the class hierarchy which could be called by the given InvokeInstruction. One reason this method is useful is that it indicates which declared exceptions are thrown by the called methods.
inv
- the InvokeInstructioncpg
- the ConstantPoolGen used by the class the InvokeInstruction
belongs tojava.lang.ClassNotFoundException
@CheckForNull public static JavaClassAndMethod findInvocationLeastUpperBound(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser methodChooser) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
@CheckForNull public static JavaClassAndMethod findInvocationLeastUpperBound(org.apache.bcel.classfile.JavaClass jClass, java.lang.String methodName, java.lang.String methodSig, JavaClassAndMethodChooser methodChooser, boolean invokeInterface) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
@Deprecated public static org.apache.bcel.generic.ObjectType[] findDeclaredExceptions(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg)
Hierarchy2.findDeclaredExceptions(InvokeInstruction,ConstantPoolGen)
insteadinv
- the InvokeInstructioncpg
- the ConstantPoolGen used by the class the InvokeInstruction
belongs to@CheckForNull public static JavaClassAndMethod findMethod(org.apache.bcel.classfile.JavaClass javaClass, java.lang.String methodName, java.lang.String methodSig)
javaClass
- the classmethodName
- the name of the methodmethodSig
- the signature of the method@CheckForNull public static JavaClassAndMethod findMethod(org.apache.bcel.classfile.JavaClass javaClass, java.lang.String methodName, java.lang.String methodSig, JavaClassAndMethodChooser chooser)
@CheckForNull public static XMethod findMethod(ClassDescriptor classDesc, java.lang.String methodName, java.lang.String methodSig, boolean isStatic)
classDesc
- the class descriptormethodName
- the name of the methodmethodSig
- the signature of the methodisStatic
- are we looking for a static method?@Deprecated @CheckForNull public static JavaClassAndMethod findConcreteMethod(org.apache.bcel.classfile.JavaClass javaClass, java.lang.String methodName, java.lang.String methodSig)
javaClass
- the classmethodName
- the name of the methodmethodSig
- the signature of the method@Deprecated @CheckForNull public static XMethod findXMethod(org.apache.bcel.classfile.JavaClass javaClass, java.lang.String methodName, java.lang.String methodSig, JavaClassAndMethodChooser chooser)
javaClass
- the classmethodName
- the name of the methodmethodSig
- the signature of the methodchooser
- the JavaClassAndMethodChooser to use to screen possible
candidatespublic static boolean accessFlagsAreConcrete(int accessFlags)
@Deprecated public static JavaClassAndMethod findMethod(org.apache.bcel.classfile.JavaClass[] classList, java.lang.String methodName, java.lang.String methodSig)
classList
- list of classes in which to searchmethodName
- the name of the methodmethodSig
- the signature of the methodpublic static JavaClassAndMethod findMethod(org.apache.bcel.classfile.JavaClass[] classList, java.lang.String methodName, java.lang.String methodSig, JavaClassAndMethodChooser chooser)
classList
- list of classes in which to searchmethodName
- the name of the methodmethodSig
- the signature of the methodchooser
- JavaClassAndMethodChooser to select which methods are
considered; it must return true for a method to be returned@Deprecated public static XMethod findXMethod(org.apache.bcel.classfile.JavaClass[] classList, java.lang.String methodName, java.lang.String methodSig)
classList
- list of classes in which to searchmethodName
- the name of the methodmethodSig
- the signature of the method@Deprecated public static XMethod findXMethod(org.apache.bcel.classfile.JavaClass[] classList, java.lang.String methodName, java.lang.String methodSig, JavaClassAndMethodChooser chooser)
classList
- list of classes in which to searchmethodName
- the name of the methodmethodSig
- the signature of the methodchooser
- JavaClassAndMethodChooser to select which methods are
considered; it must return true for a method to be returnedpublic static java.util.Set<JavaClassAndMethod> resolveMethodCallTargets(org.apache.bcel.generic.InvokeInstruction invokeInstruction, TypeFrame typeFrame, org.apache.bcel.generic.ConstantPoolGen cpg) throws DataflowAnalysisException, java.lang.ClassNotFoundException
invokeInstruction
- the InvokeInstructiontypeFrame
- the TypeFrame containing the types of stack valuescpg
- the ConstantPoolGenDataflowAnalysisException
java.lang.ClassNotFoundException
public static java.util.Set<JavaClassAndMethod> resolveMethodCallTargets(org.apache.bcel.generic.ReferenceType receiverType, org.apache.bcel.generic.InvokeInstruction invokeInstruction, org.apache.bcel.generic.ConstantPoolGen cpg) throws java.lang.ClassNotFoundException
receiverType
- type of the receiver objectinvokeInstruction
- the InvokeInstructioncpg
- the ConstantPoolGenjava.lang.ClassNotFoundException
public static java.util.Set<JavaClassAndMethod> resolveMethodCallTargets(org.apache.bcel.generic.ReferenceType receiverType, org.apache.bcel.generic.InvokeInstruction invokeInstruction, org.apache.bcel.generic.ConstantPoolGen cpg, boolean receiverTypeIsExact) throws java.lang.ClassNotFoundException
receiverType
- type of the receiver objectinvokeInstruction
- the InvokeInstructioncpg
- the ConstantPoolGenreceiverTypeIsExact
- if true, the receiver type is known exactly, which should
allow a precise resultjava.lang.ClassNotFoundException
@Deprecated public static boolean isConcrete(XMethod xmethod)
xmethod
- the methodpublic static org.apache.bcel.classfile.Field findField(java.lang.String className, java.lang.String fieldName) throws java.lang.ClassNotFoundException
className
- the name of the classfieldName
- the name of the fieldjava.lang.ClassNotFoundException
public static XField findXField(java.lang.String className, java.lang.String fieldName, java.lang.String fieldSig, boolean isStatic)
XField
object. If a field can't be found in the
immediate class, its superclass is search, and so forth.className
- name of the class through which the field is referencedfieldName
- name of the fieldfieldSig
- signature of the fieldisStatic
- true if field is static, false otherwise@CheckForNull public static XField findXField(org.apache.bcel.generic.FieldInstruction fins, @Nonnull org.apache.bcel.generic.ConstantPoolGen cpg)
XField
object.fins
- the FieldInstructioncpg
- the ConstantPoolGen used by the class containing the
instructionpublic static boolean isInnerClassAccess(org.apache.bcel.generic.INVOKESTATIC inv, org.apache.bcel.generic.ConstantPoolGen cpg)
inv
- the INVOKESTATIC instructioncpg
- the ConstantPoolGen for the methodpublic static InnerClassAccess getInnerClassAccess(org.apache.bcel.generic.INVOKESTATIC inv, org.apache.bcel.generic.ConstantPoolGen cpg) throws java.lang.ClassNotFoundException
inv
- the INVOKESTATIC instructioncpg
- the ConstantPoolGen for the methodjava.lang.ClassNotFoundException
SpotBugs is licensed under the LGPL.