Affects Version/s: Master
Component/s: Core Infrastructure
Method.isAccessible() is inherited from AccessibleObject.isAccessible().
See JavaDoc of AccessibleObject and AccessibleObject.setAccessible(boolean):
The AccessibleObject class is the base class for Field, Method and Constructor objects. It provides the ability to flag a reflected object as suppressing default Java language access control checks when it is used. The access checks-
for public, default (package) access, protected, and private members-are performed when Fields, Methods or Constructors are used to set or get fields, to invoke methods, or to create and initialize new instances of classes, respectively.Setting the accessible flag in a reflected object permits sophisticated applications with sufficient privilege, such as Java Object Serialization or other persistence mechanisms, to manipulate objects in a manner that would normally be prohibited.
By default, a reflected object is not accessible.
Set the accessible flag for this object to the indicated boolean value. A value of true indicates that the reflected object should suppress Java language access checking when it is used. A value of false indicates that the reflected object should enforce Java language access checks.
The accessible flag does not indicate whether the method represented by the object is accessible according to the modifier (public, protected, etc.), but tests whether the modifier is ignored when invoking the method through the object. And a Method object is by default with accessible=false.
So the isAccessible() test in MethodCache is redundant.