Basics of Method Invocation
by, 04-26-2012 at 06:39 PM (523 Views)
Let us revive the method invocation features present in JVM. To invoke a method new frame is made at the execution stack. Every frame consists of oerand stack and local variable array. After the frame creation, operand stack gets emptied & the local variable gets quite populated, along with this which is the target object, and arguments of method. On operand stack, all processing occurs. Maximum stack slots and local variable numbers, that are used while the invocation of method shall be known, at compile time.
At an object the method is invoked by loading method arguments and the object reference in a specified proper sequence, on operand stack. Appropriate instructions of invoke shall be used to invoke the method. Four invoke instructions are present: invokestatic, invokevirtual, invokespecial & invokeinterface. For different methods, different instructions correspond. Instance methods are invoked by the invokevirtual instructions. Static methods are invoked by invokestatic, interface methods by invokeinterface & constructors, instance methods of superclass by invokespecial.