RFR: 8009411 : getMethods should not inherit static methods from interfaces
Peter Levart
peter.levart at gmail.com
Fri Sep 13 11:15:32 UTC 2013
On 09/13/2013 12:18 PM, Peter Levart wrote:
> The C.class.getMethods() returns a 1 element array containing A.m(),
> but C.class.getMethod("m") throws NoSuchMethodException.
>
> This seems inconsistent, but it's a corner case that can only happen
> with separate compilation.
Sorry Joel, I must have tested the unpatched code for
C.class.getMethods(). In is in fact consistent with
C.calss.getMethod("m"). Both calls don't return the A.m() method. in
getMethod("m") case the recursion is stoped when B.m() static method is
encountered and in getMethods() case the inherited method A.m() is
removed from inheritedMethods array by the following in
privateGetPublicMethods():
// Filter out all local methods from inherited ones
for (int i = 0; i < methods.length(); i++) {
Method m = methods.get(i);
inheritedMethods.removeByNameAndSignature(m);
}
...when collecting B's methods...
But the question remains whether A.m() should be seen by invokeinterface
C.m() in spite of the fact that there is static B.m() in between and
whether reflection should follow that.
Regards, Peter
More information about the core-libs-dev
mailing list