import java.io.*;

public class BadGremlin implements Runnable {
    private String dir;
	
    public BadGremlin(String dir) {
	this.dir = dir;
    }
	
    public void run() {
	// Try to do some things to violate policy:
	
	// 1. We will try to modify our thread group.
		
	try {
	    // This is the group we created - we can do this.
	    System.out.println("Getting our thread group");
	    ThreadGroup g = Thread.currentThread().getThreadGroup();

	    // This is our thread group's parent - we can't do this.
	    System.out.println("Getting our thread group's group");
	    ThreadGroup pg = g.getParent();
	} catch (Exception ex) {
	    ex.printStackTrace();
	}
		
	// 2. We will try to write a file we are not supposed to write.
		
	try {
	    String path = File.separator + "x.txt";
	    System.out.println("Writing " + path);
	    FileOutputStream fos = new FileOutputStream(path);
	    fos.write(5);
	    fos.close();
	} catch (Exception ex) {
	    ex.printStackTrace();
	}
		
	System.out.println("Done");
	System.out.flush();
    }
}

