File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes compile-time method name resolution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "compile-time method name resolution" Watch "compile-time method name resolution" New topic

compile-time method name resolution

Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
This is not a question.
Back to the basics. I know that the compiler chooses the method ref.m() from the class that is the type of ref. Overriding does not occur at compile-time.

In this example, the compiler chooses method,, in methods m1, m2, m3.
I just thought of another way to see this.

#n is an index into the runtime constant pool of the current class. The runtime constant pool item at that index must be a symbolic reference to a method, which gives the name and descriptor of the method as well as a symbolic reference to the class in which the method is to be found.
9 invokevirtual #4 <Method void run()> // in m1(), #4 ==
9 invokevirtual #5 <Method void run()> // in m2(), #5 ==
9 invokevirtual #5 <Method void run()> // in m3(), #5 ==
[ August 11, 2003: Message edited by: Marlene Miller ]
I agree. Here's the link:
subject: compile-time method name resolution
It's not a secret anymore!