jeudi 6 octobre 2022

A strange clause in the documentation of java.lang.Class::getDeclaredMethods

From the documentation of java.lang.Class::getDeclaredMethods:

Returns an array containing Method objects reflecting all the declared methods of the class or interface represented by this Class object, including public, protected, default (package) access, and private methods, but excluding inherited methods. The declared methods may include methods not in the source of the class or interface, including bridge methods and other synthetic methods added by compilers. If this Class object represents a class or interface that has multiple declared methods with the same name and parameter types, but different return types, then the returned array has a Method object for each such method...

AFAIK java doesn't allow a class or an interface to have methods differing only by their return type(return type is not part of a function's signature), so how would this happen?





Aucun commentaire:

Enregistrer un commentaire