I'm trying to understand how Java's ObjectWeb ASM library (framework?) works by a combination of reading the documentation and looking at example code. I'm slowly getting the idea behind it, but I've found a bit of example code that I'm just not understanding, so I hope someone here can explain it to me.
The code takes mv
, a MethodVisitor obtained from a ClassWriter's visitMethod
method, and starts manipulating the method like this:
mv.visitCode();
String methodSignature = "(L" + worldClass + ";IIIL" + blockClass + ";)V";
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitLineNumber(81, l0);
mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ILOAD, 2);
mv.visitVarInsn(ILOAD, 3);
mv.visitVarInsn(ILOAD, 4);
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESTATIC, "com/olafski/fastleafdecay/FldHandler", "handleLeafDecay", methodSignature);
There's more to it, of course, but this is the part I don't understand. As you can see from the method signature, it takes 5 arguments: a World class, three integers, and a Block class (and yes, those variables in the signature string do hold the proper FQNs for those classes). Yet before the new method invocation is visited, only four parameters are pushed onto the stack (plus the reference to this
). So where is it getting the fifth parameter from?