Author: Chris UppalChris Uppal Date: Aug 22, 2006 08:25
Toby Kim wrote:
> While I'm writing codes on call graph construction of Java programs,
> I've got a question.
> I'm wondering how the class name in the argument of invokevirtual is
> determined.
> Is it the name of a class containing the method definition?
Not usually, at least not for Java compiled by a compiler which obeys the JLS
(there are other sources of legal bytecode, of course). The full rules are set
out in section 13.1 of the JLS (part of the binary compatibility stuff).
Ignoring various complications, the rule is that the class name is the name of
the type of the expression whose value is the target of the method invocation
(any kind of method invocation). That is /unless/ the method is one of the
methods defined by Object, in which case the class name is required to be
Object.
|