Open zhangzhen91 opened 2 months ago
Sorry, I missed that. Byte Buddy has MemberSubstitution
where you can match the method and replace it with a constant value, so this already works.
Byte Buddy does not offer a string-compiler for similar reasons to DSLs for SQL to avoid injection. Advice is the closest you would get.
@raphw firstly thanks to your great job
We were previously using the javassist framework and implemented the functionality to print out which methods were called within the getName method, as well as the ability to add a line of code before internal method calls, such as the length method, using instrument.
However, I've noticed that bytebuddy doesn't seem to have a direct way to achieve this functionality. Could you please guide me on how to implement this in bytebuddy?
`public class MethodTest {
// if (m.getClassName().equals("java.lang.String") // && m.getMethodName().equals("length")) { // m.replace("$_ = 100;"); // } } } ); ctClass.toBytecode(); MethodTest.getName(); }
}`