Hello everybody !
No doubt ASM is the best bytecode-modifier currently available. That's why I'm
using it in my PhD Thesis.
I'd like to mention a bug I think I've found.
For my current work I'm generating "proxy" classes that implement system
classes' methods. But when the program generates the body of the methods, the
automatic visitMaxs method fails.
Example :
java code corresponding :
public void sendUrgentData(int d) {
this.__linked_class__.sendUrgentData(d) ;
}
instructions to generate method :
mv = cw.visitMethod(ACC_PUBLIC,"sendUrgentData","(I)V",null,null);
mv.visitCode();
mv.visitVarInsn(ALOAD,0);
mv.visitFieldInsn(GETFIELD,"thisClass","__linked_class__","Ljava/net/Socket;");
mv.visitVarInsn(ILOAD,1);
mv.visitMethodInsn(INVOKEVIRTUAL,"java/net/Socket","sendUrgentData","(I)V");
mv.visitInsn(RETURN);
mv.visitEnd();
NB : local data = 2, stack size = 2
but the MethodVisitor created by the ClassWriter generates the following call :
mv.visitMaxs(0, 2); /* stack size = 0, local data = 2 */
That fact generates a java.lang.VerifyError at Execution time :
"Stack size too large"
But if I explicitly call mv.visitMaxs(2, 2);, everything works fine.
Shortly, in this case the automatic visitMaxs() does not give the right stack size.
By now, I'm automatically calculating maxs in my code, but it would be simplier
not to do this.
Best Regards,
Aurelien Bocquet
PhD Thesis at LIFL & INRETS-LEOST, France