Code example for PropertyPermission

Methods: newPermissionCollection

        System.out.println("Passed. OKAY");
    static void tryPropPC() throws Exception { 
        try { 
            PropertyPermission p0 = new PropertyPermission("user.home","read");
            PermissionCollection pc = p0.newPermissionCollection();
            pc.setReadOnly();   // this should lock out future adds
            PropertyPermission p1 = new PropertyPermission("java.home","read");
            throw new 
                Exception("Failed...PropertyPermission added to readonly PropertyPermissionCollection.");
        } catch (SecurityException se) {
            System.out.println("PropertyPermissionCollection passed");
    static void trySockPC() throws Exception { 
Experience pair programming with AI  Get Codota for Java