javassist
javassist copied to clipboard
Add "insertAfterLocalVariable" method on CtBehavior
Why has javassist never had a method as useful as this?
https://github.com/jboss-javassist/javassist/blob/072772373e9249e2fec67b4cde5ac36b3eefdb05/src/main/javassist/CtBehavior.java#L1314
The purpose of this method is to make changes to code where the line number or variable name is unknown or does not exist. I use it for some obfuscated code, but it doesn't work for all obfuscated code. For unobfuscated code it obviously works. The implementation is included with a test. This is the only method that got the expected result as JVM is not my area of expertise. I hope I've helped. Thank you very much and have a nice day!
Good Day, I consider in the last edition the method as complete. I was thinking of making a pull-request, but first I would like to know if the project is still alive? I didn't get any comments, is it because of your country's culture or did I write something disrespectful? I will consider silence as a zombie or dead project. Thank you, Átila César.
Well the project is not dead but its development is now very slow. But if you contribute any good code, I'm happy to merge it. Please add a good javadoc comment describing this method and also test code. The range of a local variable is often tricky. When you write test code, please check various corner cases. For example,
void foo(int x) {
int y;
do {
int z;
bar(x, y, z);
} while (expr);
:
}
Also check the case when a try-catch statement is the first statement in a method body and a local variable is declared before the statement or in its try block.