JVM Specification 8-10 inaccuracy in Chapter 6.5 -- invokespecial instruction
nlipsky at excelsior-usa.com
Fri Sep 14 08:11:39 UTC 2018
It seems I've found inaccuracy in the JVM specifications 8-10, Chapter
6.5 -- invokespecial instruction
The phrase "If the symbolic reference names a class (not an interface),
then that class is a superclass of the current class." looks like
So if the symbolic reference names an interface this whould result for
the condition to be true. However then the point 3 bellow:
" Otherwise, if C is an interface and the class Object contains a
declaration of a public instance method with the same name and
descriptor as the resolved method, then it is the method to be invoked."
will never be satisfied for classes that references methods in
interfaces as C will be a super class of the current class (in case if
the current class has "ACC_SUPER" and non-constructor should be called).
Then if we call a default method of a superinterface of the current
class it can be not found.
So I strongly believe that the phrase should be read as "The symbolic
reference names a class (not an interface) and that class is a
superclass of the current class."
HotSpot implementation follows exactly this interpretation (however it
aslo checks some conditions that are not stated by the spec: if looks
for default methods only in direct superinterfaces which is strange -- I
cannot find any place in the specification where it is stated).
More information about the jls-jvms-spec-comments