Java superinterfaces runtime difference Java 8 vs Java 9
The difference seems to be in the implementation of getMethod
API in use which is visible by the stated documentation starting Java-9 :
Within each such subset only the most specific methods are selected. Let method M be a method from a set of methods with same VM signature (return type, name, parameter types). M is most specific if there is no such method N != M from the same set, such that N is more specific than M. N is more specific than M if:
a. N is declared by a class and M is declared by an interface; or
b. N and M are both declared by classes or both by interfaces and N's declaring type is the same as or a subtype of M's declaring type (clearly, if M's and N's declaring types are the same type, then M and N are the same method).
While Java-8 follows up internally with interfaceCandidates.getFirst()
(i.e. the order change matters here), the upgraded version seems to be working on the specific algorithm using res.getMostSpecific()
before returning the method asked for.