On 19/03/2017 22:47, Jochen Theodorou wrote:
not wanting to hijack the thread, but why is there no canAccess method
that takes a class argument to check if that class can access? Why
always depending so much on caller sensitive methods?
This method is intended to be used in conjunction with
Constructor.newInstance, Method.invoke, Field.get, ... The idiom in
Peter's mail combines this with trySetAccessible and makes it easy to
gracefully handle cases where access is not allowed.
JEP 274 added Lookup.accessClass and may be closer to what you need.
-Alan