RFR: 8009411 : getMethods should not inherit static methods from interfaces

Joel Borggrén-Franck joel.franck at oracle.com
Mon Sep 9 17:36:21 UTC 2013


Hi Peter,

You are correct, thanks for noticing this. Also after reading your mail I looked through the test in test/java/lang/refledt/DefaultStaticTest/ and just realized the tests doesn't cover getMethod() at all. So this change needs more tests as well.

I'll post a new webrev later this week.

cheers
/Joel
 
On 9 sep 2013, at 19:24, Peter Levart <peter.levart at gmail.com> wrote:

> Hi Joel,
> 
> The fix is ok for getMethods(), but I think the getMethod(String name, Class<?>... parameterTypes) should also be fixed. Currently the following code:
> 
> public class StaticInterfaceMethodTest {
>     public interface A {
>         static void m() {}
>     }
> 
>     public interface B extends A {
>     }
> 
>     public static void main(String[] args) throws Exception {
>         B.class.getMethod("m");
>     }
> }
> 
> 
> ...succeeds, but should throw NoSuchMethodException, I think.
> 
> 
> Regards, Peter
> 
> On 09/09/2013 07:00 PM, Joel Borggrén-Franck wrote:
>> Hi
>> 
>> Pleaser review fix for 8009411 : getMethods should not inherit static methods from interfaces 
>> 
>> The issue is that since we added static methods to interfaces those have erroneously been reflected in getMethods of implementing classes. This fix filters out static interface methods from superinterfaces when adding methods. I have also added a note to the javadoc for both getMembers and getDeclaredMembers pointing this out (though it is implied from JLS). Webrev is based on the clarification to getMethods and friends out for review on this list.
>> 
>> Webrev: 
>> http://cr.openjdk.java.net/~jfranck/8009411/webrev.00/
>> 
>> Bug is here: 
>> http://bugs.sun.com/view_bug.do?bug_id=8009411
>> 
>> 
>> For oracle reviewers, ccc is approved.
>> 
>> cheers
>> /Joel
>> 
> 




More information about the core-libs-dev mailing list