Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Machine > Re: argument of...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 713 of 803
Post > Topic >>

Re: argument of invokevirtual

by "Chris Uppal" <chris.uppal@[EMAIL PROTECTED] > Aug 22, 2006 at 04:25 PM

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.

So in your example, if you had declared your two variables to have type
java.lang.Exception then the invokevirtual would invoke
java/lang/Exception
printStackTrace()V.  If you had declared e1 as a java.lang.Throwable then
the
invokevirtual would name that class instead.  OTOH,
equals:(Ljava/lang/Object;)Z is defined by Object, so any invocation of
that
method must name java/lang/Object.

I have, by the way, no idea at all what benefit there is supposed to be in
making java.lang.Object a special case.  I suspect there is none...

    -- chris




 3 Posts in Topic:
argument of invokevirtual
"Toby Kim" <  2006-08-22 06:57:24 
Re: argument of invokevirtual
Thomas Hawtin <usenet@  2006-08-22 17:09:06 
Re: argument of invokevirtual
"Chris Uppal" &  2006-08-22 16:25:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 2:52:38 CDT 2008.