On 05/01/2017 20:07, Phil Race wrote:
Sort of .. it depends whether you could use getDeclaredMethod instead.
One question I have is, how would you update the code if you
were given the instance "foo", and need to programmatically
work out what is the correct super-type of Foo that exports
the interface method "bar" ?
i.e you don't have the string "java.awt.Toolkit" handy and
need to infer it from the instance class.
There have been a couple of threads here (going back to 2015) on this
topic. Peter included a method [1] in one threads to walk the
superclasses and directly implemented interface of each class to find
the accessible method. Rony's example might need someone like this if
the reference to java.awt.Toolkit is not available.
-Alan
[1]
http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-September/009357.html