Class.getDeclaredMethods() is returning inherited methods

Steve Groeger GROEGES at uk.ibm.com
Wed Jan 2 16:33:53 UTC 2019


I am looking into an issue where the Class.getDeclaredMethods() is 
returning inherited methods, 
where the Java Doc here:- 
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html#getDeclaredMethods() 
states:-

"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".

with the last part of the statement being the relevant part, "but 
excluding inherited methods"

This was raised as an issue a long time ago: 
https://bugs.openjdk.java.net/browse/JDK-6815786 but has not been fixed 
and is still an issue in JDK11.

Before I go looking into why this is occurring and producing a fix, is 
this still seen as an issue and does it need to be fixed / should it be 
fixed. 
I dont want to do lots of investigation and produce a fix just to be told 
we cant contribute this as it will break too many people that might have 
been using this feature !!!!

Thanks
Steve Groeger
IBM Runtime Technologies
Hursley, Winchester
Tel: (44) 1962 816911  Mobex: 279990  Mobile: 07718 517 129
Fax (44) 1962 816800
Lotus Notes: Steve Groeger/UK/IBM
Internet: groeges at uk.ibm.com

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


More information about the core-libs-dev mailing list