Hi. Sorry for the very late reply, late summer holidays... > Another issue is when we search a tree, e.g. invokevirtual #C::f(), we > load class file C (suppose it can be loaded), and find f() is not defined > within the class file, do we just need to look for C's superclasses?
When you write C::f() people mean the method syntactically specified in the bytecode, not the result of method resolution (5.4.3.3 of the Java virtual machine official specification). Note that the resolved method is only known at run-time, unless you assume that the class hierarchy is immutable. Anyway, the resolved method must exist by definition. The syntactical method might not exist. The target object (what you have on the operand stack at call-time) must be assignment-compatible with the class of the syntactical method. Hence, if this method does not exist, you might end up calling a method of a superclass of C. Namely, the resolved method. But you can also call all redefinitions of f() in the subclasses of C. > On the other hand, > if there is a definition of f() in C's class file, we just need to look > for C's subclasses since f() may be overridden. Correct me if I was wrong. This is corrected, because in this case the resolved method coincides with the syntactical method. Note that resolution uses accessibility modifiers to find the resolved method. This makes things still more complicated... Fausto --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
