This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compile-time method name resolution

Marlene Miller
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic