What is the pattern for such assignment in bytecode?
Hi,
I wish to identify the assignment pattern in the bytecode, which corresponds to the language level: variable = method_invocation; where variable may be a local, or field. Is it always safe to say the following?
This pattern is: the invokevirtual/invokeinterface..., immediately folllowed by putfield/astore ...
Is it possible for different compilers to generate different bytecode for such assignment statements? Thank you very much!
-- Sunny
Probably only for the very simplest of assignments, eg.
int a = getInt();
But I imagine more complicated assignments such as
int a, b;
a = b = getInt();
myClass.a = getInt();
a = anotherRef.getInt();
could complicate matters.
You cannot always assume that other programmers will only ever use the same programming constructs as yourself.
regards,
Owen
Hi Owen,
Thank you for your example. So one set of bytecode (eg, virtualinvoke followed by putfield) could correspond to several phenomenon (different statements) in java source level and vice versa - one jave source level code could be translated into different bytecode by different compilers. Is that right?
Nice day,
-- Sunny