RFR: 8177086: java.lang.reflect.AccessibleObject::canAccess should share access cache with internal method ::checkAccess

Alan Bateman Alan.Bateman at oracle.com
Mon Mar 20 09:04:12 UTC 2017


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


More information about the jigsaw-dev mailing list