Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.reflect.Member;

public class Main extends SecurityManager {

    // checkMemberAccess needs to be overriden.
    @Override
    public void checkMemberAccess(Class<?> clazz, int which) {
        throw new SecurityException();
    }

    public static void main(String[] args) {
        System.setProperty("java.security.policy", "file:/C:/java.policy");

        SecurityManager sm = new Main();

        System.setSecurityManager(sm);

        sm.checkMemberAccess(Main.class, Member.PUBLIC);

        System.out.println("Allowed!");
    }
}