Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-84318

Remove redundant check when set accessible to true in MethodCache

    Details

      Description

      Method.isAccessible() is inherited from AccessibleObject.isAccessible().

      See JavaDoc of AccessibleObject and AccessibleObject.setAccessible(boolean):

      AccessibleObject:
      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.

      AccessibleObject.setAccessible(boolean):

      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.

        Attachments

          Activity

            People

            • Assignee:
              brian.chan Brian Chan
              Reporter:
              leon.chi Leon Chi
              Participants of an Issue:
              Recent user:
              Csaba Turcsan
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 6 weeks, 1 day ago

                Packages

                Version Package
                7.1.10 DXP FP2
                7.1.1 CE GA2
                7.1.10.1 SP1
                7.1.X
                Master