My problem with this is:
1. aload_0 is supposed to push 'this' on to the stack (thats what the JVM spec seems to say)
2. arraylength is supposed to return the length of the array whose reference is on the top-of-stack

So according to me the combination of 1 & 2 should not even work.

How/why is it working? Or is the disassembler buggy and the actual bytecode is something else?

1 Answer
1

Not quite … aload_0 reads the first argument of the method. In member functions, this happens to be the this reference. But main is not a member function, it’s a static function so there is no this argument, and the true first argument of the method is args.