Using java.awt.Toolkit.getDefaultToolkit().getScreenSize() reflectively causes InaccessibleObjectException

Michael Rasmussen michael.rasmussen at zeroturnaround.com
Fri Jan 6 12:52:31 UTC 2017


On 6 January 2017 at 10:24, Alan Bateman <Alan.Bateman at oracle.com> wrote:

> 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-Septe
> mber/009357.html
>
>
getAccessibleMethods() / getAccessibleMethod(...) as described in that
post; with the increased complexity of accessibility with jigsaw, wouldn't
it make sense to have such methods available on Class?

Personally, I've always found the Class.getMethods() / getMethod(...) to be
a bit flawed, in that the returned public methods could be inaccessible, in
case they were declared on a non-public class. Previously, we could poke
holes using setAccessible, but that is no longer the case.

/Michael


More information about the jigsaw-dev mailing list