Utility for working with Javassist and patching methods.
public String hello() {
return "Hello world";
}
public String hello(String world, boolean b) {
return "Hello " + world;
}
Get method signature
String sign = PatchUtils.getJavaMethodSignature(ctMethod);
// Output: hello(java.lang.String)
Get method by return data type
CtMethod hello = PatchUtils.getMethodByReturn("hello", "java.lang.String", ctClass);
Get method by parameters
CtMethod hello = PatchUtils.getMethodByParams("hello", "java.lang.String", ctClass,
"java.lang.String",
"java.lang.Boolean");
Check if the signature matches
boolean signed = PatchUtils.checkSignature(ctMethod,
"java.lang.String",
"java.lang.Boolean");
There are also several methods for inserting code and replacing methods.
JPU is an open source project distributed under the Apache License 2.0
- Download the latest build from releases
- Read the FAQ and examples
- Enjoy!
The project is in beta. Use at your own risk.