Package proguard.analysis
Class CallUtil
java.lang.Object
proguard.analysis.CallUtil
Utility methods for call resolution.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidgetSuperinterfaces(Clazz start, Set<Clazz> accumulator) Get the transitive superinterfaces of a class/interface recursively.resolveFromSuperclasses(Clazz start, String name, String descriptor) Search for the invocation target in a specific class and recursively in all superclasses.resolveFromSuperinterfaces(Clazz start, String name, String descriptor) Search for a maximally specific default implementation in all superinterfaces of a class.resolveVirtual(Clazz thisPointerType, String methodName, String descriptor) Theinvokevirtualandinvokeinterfaceresolution algorithm, annotated with JVM spec §6.5.invokevirtual citations where appropriate, so that the specified lookup process can easily be compared to this implementation.resolveVirtual(Clazz callingClass, Clazz thisPointerType, AnyMethodrefConstant ref) Theinvokevirtualandinvokeinterfaceresolution algorithm, annotated with JVM spec §6.5.invokevirtual citations where appropriate, so that the specified lookup process can easily be compared to this implementation.static Set<MethodSignature>resolveVirtualSignatures(Clazz thisPointerType, String methodName, String descriptor) Adapter ofresolveVirtual(Clazz, String, String)returningMethodSignature.
-
Method Details
-
resolveVirtual
public static Set<String> resolveVirtual(Clazz callingClass, Clazz thisPointerType, AnyMethodrefConstant ref) Theinvokevirtualandinvokeinterfaceresolution algorithm, annotated with JVM spec §6.5.invokevirtual citations where appropriate, so that the specified lookup process can easily be compared to this implementation.- Parameters:
callingClass- JVM spec: "current class".thisPointerType- The type of thethispointer of the call (JVM spec: "objectref").ref- TheAnyMethodrefConstantspecifying name and descriptor of the method to be invoked.- Returns:
- The fully qualified names of potential call target clases (usually just one, but see
resolveFromSuperinterfaces(Clazz, String, String)for details on when there might be multiple).
-
resolveVirtual
public static Set<String> resolveVirtual(Clazz thisPointerType, String methodName, String descriptor) Theinvokevirtualandinvokeinterfaceresolution algorithm, annotated with JVM spec §6.5.invokevirtual citations where appropriate, so that the specified lookup process can easily be compared to this implementation.- Parameters:
thisPointerType- The type of thethispointer of the call (JVM spec: "objectref").methodName- The name of the invoked method.descriptor- The descriptor of the invoked method.- Returns:
- The fully qualified names of potential call target clases (usually just one, but see
resolveFromSuperinterfaces(Clazz, String, String)for details on when there might be multiple).
-
resolveVirtualSignatures
public static Set<MethodSignature> resolveVirtualSignatures(Clazz thisPointerType, String methodName, String descriptor) Adapter ofresolveVirtual(Clazz, String, String)returningMethodSignature.- Parameters:
thisPointerType- The type of thethispointer of the call (JVM spec: "objectref").methodName- The name of the invoked method.descriptor- The descriptor of the invoked method.- Returns:
- The
MethodSignatures of potential call target (usually just one, but seeresolveFromSuperinterfaces(Clazz, String, String)for details on when there might be multiple).
-
resolveFromSuperclasses
Search for the invocation target in a specific class and recursively in all superclasses. -
resolveFromSuperinterfaces
Search for a maximally specific default implementation in all superinterfaces of a class. This step is potentially unintuitive and difficult to grasp, see JVM spec §5.4.3.3 for more information, as well as this great blog post concerning the resolution pitfalls. The following is based on the information on those websites.- Parameters:
start- TheClazzwhose superinterfaces are to be searched.name- The target method name.descriptor- The target method descriptor.- Returns:
- The fully qualified name of the class(es) that contain the method to be invoked. Be aware that purely from a JVM point of view, this choice can be ambiguous, in which case it just chooses the candidate randomly. Here, we don't want to gamble, but rather want to add call graph edges for every possibility, if this ever happens. Javac ensures that such a case never occurs, but who knows how the bytecode has been generated, so this possibility is implemented just in case.
-
getSuperinterfaces
Get the transitive superinterfaces of a class/interface recursively.- Parameters:
start- TheClazzwhere the collection process is to be started.accumulator- The current set of superinterfaces, so that only one set is constructed at runtime.
-