-
Notifications
You must be signed in to change notification settings - Fork 0
MethodSignatureConverter
Jordan Samhi edited this page Aug 22, 2023
·
2 revisions
The MethodSignatureConverter
class is part of the AndroSpecter library and serves as a utility class for converting Java method signatures to Soot method signatures and extracting various components of method signatures.
The class offers one constructor:
-
public MethodSignatureConverter()
: Constructs a newMethodSignatureConverter
object.
-
public static MethodSignatureConverter v()
: Returns the singleton instance ofMethodSignatureConverter
.
-
public String getClassNameFromJimpleSignature(String sig)
: Extracts and returns the class name from the given Jimple signature. -
public String getMethodNameFromJimpleSignature(String sig)
: Extracts and returns the method name from the given Jimple signature. -
public String getReturnNameFromJimpleSignature(String sig)
: Extracts and returns the return type from the given Jimple signature. -
public List<String> getParametersNamesFromJimpleSignature(String sig)
: Extracts and returns the list of parameter types from the given Jimple signature. An empty list is returned if no parameters exist. -
public String javaSigToSootSig(String sig)
: Converts a Java signature to a Soot signature. -
public String sigToSubSig(String sig)
: Extracts the sub-signature from a given signature string.
Here is an example of how to use the MethodSignatureConverter
class:
MethodSignatureConverter converter = MethodSignatureConverter.v();
// Jimple signature example
String jimpleSignature = "<com.example.MyClass: void myMethod(java.lang.String,int,boolean)>(\"String\",1,true)";
// Extracting class name
String className = converter.getClassNameFromJimpleSignature(jimpleSignature); // Result: "com.example.MyClass"
// Extracting method name
String methodName = converter.getMethodNameFromJimpleSignature(jimpleSignature); // Result: "myMethod"
// Extracting return type
String returnType = converter.getReturnNameFromJimpleSignature(jimpleSignature); // Result: "void"
// Extracting parameters
List<String> parameters = converter.getParametersNamesFromJimpleSignature(jimpleSignature); // Result: ["java.lang.String", "int", "boolean"]
// Extracting sub-signature
String subSignature = converter.sigToSubSig(jimpleSignature); // Result: "void myMethod(java.lang.String,int,boolean)"