On 13/12/2016 15:47, Rony G. Flatscher wrote:

:

So the current code does not take protected members into account. If protected 
members (cf. Alex'
comment)  get added, wouldn't e.g. java.lang.reflect.Method.invoke(...)  or
java.lang.reflect.Field.get(...) be the place to check in the next step, 
throwing an
IllegalAccessException if the object is not instantiated from a subclass of the 
class the protected
method to invoke or protected Field to get is defined?

If you mean you are asking for setAccessible(true) to succeed but still do the access check then it will cause a lot of complications.

So I'm curious, are you calling setAccessible on protected members that you do have access or not? If you do have access (you are in the same package or a sub-type) then you don't need to call setAccessible. On the other hand, if you are looking to use the AccessibleObject to get into a different subtype then you are out of luck, the package needs to be open to you to do that.

-Alan

Reply via email to