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.
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 B.run(), A.run(), A.run() 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 == B.run() 9 invokevirtual #5 <Method void run()> // in m2(), #5 == A.run() 9 invokevirtual #5 <Method void run()> // in m3(), #5 == A.run() [ August 11, 2003: Message edited by: Marlene Miller ]