javassist icon indicating copy to clipboard operation
javassist copied to clipboard

Add "insertAfterLocalVariable" method on CtBehavior

Open Adahel opened this issue 2 years ago • 2 comments

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!

Adahel avatar Aug 31 '22 22:08 Adahel

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.

Adahel avatar Sep 26 '22 13:09 Adahel

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.

chibash avatar Sep 26 '22 15:09 chibash