Package edu.umd.cs.findbugs.ba
Class Hierarchy2
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.Hierarchy2
-
public class Hierarchy2 extends java.lang.ObjectFacade for class hierarchy queries. These typically access the class hierarchy using theRepositoryclass. Callers should generally expect to handle ClassNotFoundException for when referenced classes can't be found.
-
-
Field Summary
Fields Modifier and Type Field Description private static ClassDescriptorobjectDescriptorprivate static booleanOPEN_WORLDprivate static booleanOPEN_WORLD_DEBUG
-
Constructor Summary
Constructors Constructor Description Hierarchy2()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.bcel.generic.ObjectType @Nullable []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 XMethodfindExactMethod(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser chooser)Look up the method referenced by given InvokeInstruction.static @Nullable XMethodfindFirstSuperMethod(XMethod m)static @Nullable XMethodfindInvocationLeastUpperBound(XClass jClass, java.lang.String methodName, java.lang.String methodSig, boolean invokeStatic, boolean invokeInterface)static @Nullable XMethodfindInvocationLeastUpperBound(ClassDescriptor classDesc, java.lang.String methodName, java.lang.String methodSig, boolean invokeStatic, boolean invokeInterface)static @Nullable XMethodfindInvocationLeastUpperBound(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser methodChooser)static @Nullable XMethodfindInvocationLeastUpperBound0(XClass jClass, java.lang.String methodName, java.lang.String methodSig, boolean invokeStatic, boolean invokeInterface)static @Nullable XMethodfindMethod(ClassDescriptor classDescriptor, java.lang.String methodName, java.lang.String methodSig, boolean isStatic)private static voidfindSuperMethods(@Nullable ClassDescriptor c, XMethod m, java.util.Set<XMethod> accumulator)static java.util.Set<XMethod>findSuperMethods(XMethod m)(package private) static XClassgetXClass(ClassDescriptor c)(package private) static XClassgetXClass(java.lang.String c)(package private) static XClassgetXClassFromDottedClassName(java.lang.String c)static @NonNull java.util.Set<XMethod>resolveMethodCallTargets(org.apache.bcel.generic.InvokeInstruction invokeInstruction, TypeFrame typeFrame, org.apache.bcel.generic.ConstantPoolGen cpg)Resolve possible method call targets.static java.util.Set<XMethod>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<XMethod>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 java.util.Set<XMethod>resolveVirtualMethodCallTargets(XMethod target, boolean receiverTypeIsExact, boolean invokeSpecial)static java.util.Set<XMethod>resolveVirtualMethodCallTargets(ClassDescriptor receiverDesc, java.lang.String methodName, java.lang.String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial)static java.util.Set<XMethod>resolveVirtualMethodCallTargets(java.lang.String receiverClassName, java.lang.String methodName, java.lang.String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial)private static @Nullable XMethodthisOrNothing(@Nullable XMethod m, JavaClassAndMethodChooser chooser)
-
-
-
Field Detail
-
objectDescriptor
private static final ClassDescriptor objectDescriptor
-
OPEN_WORLD
private static final boolean OPEN_WORLD
-
OPEN_WORLD_DEBUG
private static final boolean OPEN_WORLD_DEBUG
-
-
Method Detail
-
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
private static @Nullable XMethod thisOrNothing(@Nullable XMethod m, JavaClassAndMethodChooser chooser)
-
findInvocationLeastUpperBound
public static @Nullable XMethod findInvocationLeastUpperBound(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg, JavaClassAndMethodChooser methodChooser)
-
findInvocationLeastUpperBound
public static @Nullable XMethod findInvocationLeastUpperBound(ClassDescriptor classDesc, java.lang.String methodName, java.lang.String methodSig, boolean invokeStatic, boolean invokeInterface)
-
findInvocationLeastUpperBound
public static @Nullable XMethod findInvocationLeastUpperBound(XClass jClass, java.lang.String methodName, java.lang.String methodSig, boolean invokeStatic, boolean invokeInterface)
-
findInvocationLeastUpperBound0
public static @Nullable XMethod findInvocationLeastUpperBound0(XClass jClass, java.lang.String methodName, java.lang.String methodSig, boolean invokeStatic, boolean invokeInterface)
-
findSuperMethods
private static void findSuperMethods(@Nullable ClassDescriptor c, XMethod m, java.util.Set<XMethod> accumulator)
-
findMethod
public static @Nullable XMethod findMethod(ClassDescriptor classDescriptor, java.lang.String methodName, java.lang.String methodSig, boolean isStatic)
-
getXClass
static XClass getXClass(@SlashedClassName java.lang.String c) throws CheckedAnalysisException
- Throws:
CheckedAnalysisException
-
getXClassFromDottedClassName
static XClass getXClassFromDottedClassName(@DottedClassName java.lang.String c) throws CheckedAnalysisException
- Throws:
CheckedAnalysisException
-
getXClass
static XClass getXClass(ClassDescriptor c) throws CheckedAnalysisException
- Throws:
CheckedAnalysisException
-
resolveMethodCallTargets
public static @NonNull java.util.Set<XMethod> resolveMethodCallTargets(org.apache.bcel.generic.InvokeInstruction invokeInstruction, TypeFrame typeFrame, org.apache.bcel.generic.ConstantPoolGen cpg) throws DataflowAnalysisException, java.lang.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:
DataflowAnalysisExceptionjava.lang.ClassNotFoundException
-
resolveMethodCallTargets
public static java.util.Set<XMethod> resolveMethodCallTargets(org.apache.bcel.generic.ReferenceType receiverType, org.apache.bcel.generic.InvokeInstruction invokeInstruction, org.apache.bcel.generic.ConstantPoolGen cpg) throws java.lang.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:
java.lang.ClassNotFoundException
-
resolveMethodCallTargets
public static java.util.Set<XMethod> 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
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:
java.lang.ClassNotFoundException
-
resolveVirtualMethodCallTargets
public static java.util.Set<XMethod> resolveVirtualMethodCallTargets(java.lang.String receiverClassName, java.lang.String methodName, java.lang.String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
resolveVirtualMethodCallTargets
public static java.util.Set<XMethod> resolveVirtualMethodCallTargets(XMethod target, boolean receiverTypeIsExact, boolean invokeSpecial) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
resolveVirtualMethodCallTargets
public static java.util.Set<XMethod> resolveVirtualMethodCallTargets(ClassDescriptor receiverDesc, java.lang.String methodName, java.lang.String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
findDeclaredExceptions
public static org.apache.bcel.generic.ObjectType @Nullable [] 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
-
-