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.
aload_0 is supposed to push 'this' on to the stack
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 thisargument,
and the true first argument of the method is args.