Package edu.umd.cs.findbugs.ba
Class Hierarchy2
java.lang.Object
edu.umd.cs.findbugs.ba.Hierarchy2
Facade for class hierarchy queries. These typically access the class
hierarchy using the
Repository
class. Callers should
generally expect to handle ClassNotFoundException for when referenced classes
can't be found.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ClassDescriptor
private static final boolean
private static final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.bcel.generic.ObjectType[]
findDeclaredExceptions
(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg) Find the declared exceptions for the method called by given instruction.static XMethod
findExactMethod
(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser chooser) Look up the method referenced by given InvokeInstruction.static XMethod
static XMethod
findInvocationLeastUpperBound
(XClass jClass, String methodName, String methodSig, boolean invokeStatic, boolean invokeInterface) static XMethod
findInvocationLeastUpperBound
(ClassDescriptor classDesc, String methodName, String methodSig, boolean invokeStatic, boolean invokeInterface) static XMethod
findInvocationLeastUpperBound
(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser methodChooser) static XMethod
findInvocationLeastUpperBound0
(XClass jClass, String methodName, String methodSig, boolean invokeStatic, boolean invokeInterface) static XMethod
findMethod
(ClassDescriptor classDescriptor, String methodName, String methodSig, boolean isStatic) private static void
findSuperMethods
(ClassDescriptor c, XMethod m, Set<XMethod> accumulator) (package private) static XClass
(package private) static XClass
(package private) static XClass
resolveMethodCallTargets
(org.apache.bcel.generic.InvokeInstruction invokeInstruction, TypeFrame typeFrame, org.apache.bcel.generic.ConstantPoolGen cpg) Resolve possible method call targets.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.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.resolveVirtualMethodCallTargets
(XMethod target, boolean receiverTypeIsExact, boolean invokeSpecial) resolveVirtualMethodCallTargets
(ClassDescriptor receiverDesc, String methodName, String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial) resolveVirtualMethodCallTargets
(String receiverClassName, String methodName, String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial) private static XMethod
thisOrNothing
(XMethod m, JavaClassAndMethodChooser chooser)
-
Field Details
-
objectDescriptor
-
OPEN_WORLD
private static final boolean OPEN_WORLD -
OPEN_WORLD_DEBUG
private static final boolean OPEN_WORLD_DEBUG
-
-
Constructor Details
-
Hierarchy2
public Hierarchy2()
-
-
Method Details
-
findExactMethod
public static XMethod findExactMethod(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser chooser) Look up the method referenced by given InvokeInstruction. This method does not look for implementations in super or subclasses according to the virtual dispatch rules.- Parameters:
inv
- the InvokeInstructioncpg
- the ConstantPoolGen used by the class the InvokeInstruction belongs tochooser
- JavaClassAndMethodChooser to use to pick the method from among the candidates- Returns:
- the JavaClassAndMethod, or null if no such method is defined in the class
-
thisOrNothing
@CheckForNull private static XMethod thisOrNothing(@CheckForNull XMethod m, JavaClassAndMethodChooser chooser) -
findInvocationLeastUpperBound
@CheckForNull public static XMethod findInvocationLeastUpperBound(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser methodChooser) -
findInvocationLeastUpperBound
@CheckForNull public static XMethod findInvocationLeastUpperBound(ClassDescriptor classDesc, String methodName, String methodSig, boolean invokeStatic, boolean invokeInterface) -
findInvocationLeastUpperBound
-
findInvocationLeastUpperBound0
-
findSuperMethods
-
findFirstSuperMethod
-
findSuperMethods
private static void findSuperMethods(@CheckForNull ClassDescriptor c, XMethod m, Set<XMethod> accumulator) -
findMethod
@CheckForNull public static XMethod findMethod(ClassDescriptor classDescriptor, String methodName, String methodSig, boolean isStatic) -
getXClass
- Throws:
CheckedAnalysisException
-
getXClassFromDottedClassName
static XClass getXClassFromDottedClassName(@DottedClassName String c) throws CheckedAnalysisException - Throws:
CheckedAnalysisException
-
getXClass
- Throws:
CheckedAnalysisException
-
resolveMethodCallTargets
@Nonnull public static Set<XMethod> resolveMethodCallTargets(org.apache.bcel.generic.InvokeInstruction invokeInstruction, TypeFrame typeFrame, org.apache.bcel.generic.ConstantPoolGen cpg) throws DataflowAnalysisException, ClassNotFoundException Resolve possible method call targets. This works for both static and instance method calls.- Parameters:
invokeInstruction
- the InvokeInstructiontypeFrame
- the TypeFrame containing the types of stack valuescpg
- the ConstantPoolGen- Returns:
- Set of methods which might be called
- Throws:
DataflowAnalysisException
ClassNotFoundException
-
resolveMethodCallTargets
public static Set<XMethod> resolveMethodCallTargets(org.apache.bcel.generic.ReferenceType receiverType, org.apache.bcel.generic.InvokeInstruction invokeInstruction, org.apache.bcel.generic.ConstantPoolGen cpg) throws ClassNotFoundException Resolve possible instance method call targets. Assumes that invokevirtual and invokeinterface methods may call any subtype of the receiver class.- Parameters:
receiverType
- type of the receiver objectinvokeInstruction
- the InvokeInstructioncpg
- the ConstantPoolGen- Returns:
- Set of methods which might be called
- Throws:
ClassNotFoundException
-
resolveMethodCallTargets
public static Set<XMethod> resolveMethodCallTargets(org.apache.bcel.generic.ReferenceType receiverType, org.apache.bcel.generic.InvokeInstruction invokeInstruction, org.apache.bcel.generic.ConstantPoolGen cpg, boolean receiverTypeIsExact) throws ClassNotFoundException Resolve possible instance method call targets.- Parameters:
receiverType
- type of the receiver objectinvokeInstruction
- the InvokeInstructioncpg
- the ConstantPoolGenreceiverTypeIsExact
- if true, the receiver type is known exactly, which should allow a precise result- Returns:
- Set of methods which might be called
- Throws:
ClassNotFoundException
-
resolveVirtualMethodCallTargets
public static Set<XMethod> resolveVirtualMethodCallTargets(String receiverClassName, String methodName, String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
resolveVirtualMethodCallTargets
public static Set<XMethod> resolveVirtualMethodCallTargets(XMethod target, boolean receiverTypeIsExact, boolean invokeSpecial) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
resolveVirtualMethodCallTargets
public static Set<XMethod> resolveVirtualMethodCallTargets(ClassDescriptor receiverDesc, String methodName, String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
findDeclaredExceptions
@CheckForNull public static org.apache.bcel.generic.ObjectType[] findDeclaredExceptions(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg) Find the declared exceptions for the method called by given instruction.- Parameters:
inv
- the InvokeInstructioncpg
- the ConstantPoolGen used by the class the InvokeInstruction belongs to- Returns:
- array of ObjectTypes of thrown exceptions, or null if we can't find the method implementation
-