java

2020-12-21T15:30:19.159400Z

At run time we can do reflection on a Java class / interface to get a list of all of its methods, and the signature of the method, e.g. return type, number of parameters and their types. I know that a method in a class is considered to implement a method signature in an interface if the return type, number of parameters, and types of all parameters are equal, but I believe that there are other cases where the return type and/or parameter types are not equal, but "compatible", that the class's method is also considered to implement the method of the interface. Does anyone have precise rules, and/or some JVM library function, that determines whether a class's method implements an interface's method signature?

alexmiller 2020-12-21T15:40:00.159600Z

this is all in the specs

alexmiller 2020-12-21T15:40:59.160100Z

I assume you're talking about subtypes and covariant return types etc?

alexmiller 2020-12-21T15:41:27.160300Z

if so, see the java language spec