Question about byte code instructions

Dear All,

A method invocation (e.g., invokevirtual) needs its arguments to be prepared by the instructions above the method invocation instruction.

As we know, some instructions pop objects out of the stack (eg, putfield), some instructions push objects onto the stack (eg, getfield), and some instructions do not change the state of the stack.

My question is: are the instructions corresponding each argument preparation only those instruction that can push objects onto the stack, or could be any other?

Thank you very much,

-- Sunny

[574 byte] By [Sunny_Daya] at [2007-10-3 7:44:26]
# 1

When you say that arguments need to be prepared "above" the method invocation, it's more accurate to say before the method invocation.

Typically, the stack is prepared with parameters which have been pushed onto it. But that's not just for method invocation.Simple operations such as "c = a + b" do not invoke any class methods, they are implemented by bytecode operations.If you had"myTestMethod ( a + b )", then the parameters preparation also includes calculations, the results of which are left on the stack for the method invocation.

regards,

Owen

omcgoverna at 2007-7-15 2:45:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Hi Owen,Thanks a lot for your help!Sunny
Sunny_Daya at 2007-7-15 2:45:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...