Class PrivilegedAccessor


  • public class PrivilegedAccessor
    extends Object
    a.k.a. The "ObjectMolester"

    This class is used to access a method or field of an object no matter what the access modifier of the method or field. The syntax for accessing fields and methods is out of the ordinary because this class uses reflection to peel away protection.

    Here is an example of using this to access a private member. resolveName is a private method of Class.

     Class c = Class.class;
     System.out.println(PrivilegedAccessor.invokeMethod(c, "resolveName","/ise/library/PrivilegedAccessor"));