Class AccessManager


  • public class AccessManager
    extends Object
    Methods for checking Java scope and visibility requirements.
    • Method Detail

      • isAccessLegal

        public static boolean isAccessLegal​(SootMethod container,
                                            ClassMember target)
        Returns true iff target is legally accessible from container. Illegal access occurs when any of the following cases holds: (1) target is private, but container.declaringClass() != target.declaringClass(); or, (2) target is package-visible (i.e. default), and its package differs from that of container; or, (3) target is protected and the package of container differs from the package of target and the container doesn't belong to target.declaringClass or any subclass.
      • isAccessLegal

        public static boolean isAccessLegal​(SootMethod container,
                                            SootClass target)
        Returns true if an access to target is legal from code in container.
      • isAccessLegal

        public static boolean isAccessLegal​(SootMethod container,
                                            Stmt stmt)
        Returns true if the statement stmt contains an illegal access to a field or method, assuming the statement is in method container
        Parameters:
        container -
        stmt -
        Returns:
      • createAccessorMethods

        public static void createAccessorMethods​(Body body,
                                                 Stmt before,
                                                 Stmt after)
        Resolves illegal accesses in the interval ]before,after[ by creating accessor methods. before and after can be null to indicate beginning/end respectively.
        Parameters:
        body -
        before -
        after -
      • createAccessorName

        public static String createAccessorName​(ClassMember member,
                                                boolean setter)
        Creates a name for an accessor method.
        Parameters:
        member -
        setter -
        Returns:
      • createAccessorMethod

        public static void createAccessorMethod​(SootMethod container,
                                                Stmt stmt)
        Turns a field access or method call into a call to an accessor method. Reuses existing accessors based on name mangling (see createAccessorName)
        Parameters:
        container -
        stmt -
      • ensureAccess

        public static boolean ensureAccess​(SootMethod container,
                                           ClassMember target,
                                           String options)
        Modifies code so that an access to target is legal from code in container. The "accessors" option assumes suitable accessor methods will be created after checking.
      • ensureAccess

        public static boolean ensureAccess​(SootMethod container,
                                           SootClass target,
                                           String options)
        Modifies code so that an access to target is legal from code in container.