Code example for FileDescriptor

0
    public void test_checkReadLjava_io_FileDescriptor() { 
        // enable all but one check 
        mutableSM.addPermission(new AllPermission());
        mutableSM.denyPermission(new RuntimePermission("readFileDescriptor"));
        try { 
            mutableSM.checkRead(new FileDescriptor());
            fail("This should throw a SecurityException.");
        } catch (SecurityException e) {
            // expected 
        } 
    } 
 
    /** 
     * @tests {@link java.lang.SecurityManager#checkRead(String,Object)} 
     */ 
    @SuppressWarnings("nls") 
    public void test_checkReadLjava_lang_StringLjava_lang_Object() { 
        // enable all but one check 
        mutableSM.addPermission(new AllPermission());
        mutableSM.denyPermission(new FilePermission("<<ALL FILES>>", "read"));
        ProtectionDomain pDomain = this.getClass().getProtectionDomain();