Hello everyone,

I have a problem with java's ClassLoader.

I have written an java applet with inside the, by my written simple, ClassLoader. (Sources below)
The java applet jar file is signed.
Now when the ClassLoader starts he loads and calls "theClass". (Sources below)

When I run the applet in my browser and click "run" at the security warning the program starts, calls "theClass" and print in the console: "From theClass: Hello World!", that part works finely.

Then the second output has to be: "From theClass: " + System.getProperty("java.io.tmpdir")
But because that is an permission-needed call I get an error. (Error code below)

I don't know how so grant permission to the ClassLoader or classes in the ClassLoader.
I've read something about the java class "RuntimePermission", but there is no way to grant the RuntimePermission to the ClassLoader.

I hope someone could tell me how to grant permissions to a ClassLoader or if there is another way to make this possible.

Thanks,

Dennis

Sources/Error code:

loader.java
Java Code:
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;


public class loader extends java.applet.Applet
{
	public void init()
	{
		c cl = new c(ClassLoader.getSystemClassLoader());
		cl.getClass("theClass", getFileContent(new File("/media/Data/workspace/ClassLoaderTest/test1Classes/bin/theClass.class")));
		try{
			Class<?> c = cl.loadClass("theClass");
			c.newInstance();
		}catch(ClassNotFoundException ex){
			ex.printStackTrace();
		}catch(InstantiationException ex){
			ex.printStackTrace();
		}catch(IllegalAccessException ex){
			ex.printStackTrace();
		}
	}
	
	private byte[] getFileContent(File f)
	{
		if(f.exists()){
			try {
				FileInputStream fis = new FileInputStream(f);
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				int r=0;
				while(r<f.length())
				{
					byte[] b = new byte[(int) (f.length()-r)];
					try {
						int n = fis.read(b, 0, ((int)f.length())-r);
						baos.write(B);
						r+=n;
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				return baos.toByteArray();
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}
My ClassLoader: c.java:
Java Code:
public class c extends ClassLoader
{
	public c()
	{
		super();
	}
	
	public c(ClassLoader cl)
	{
		super(cl);
	}
	
	public void getClass(String s, byte[] B)
	{
		if(b!=null)
			defineClass(s, b, 0, b.length); // protected function
	}
}
The by ClassLoader loaded class: theClass.java (in an extern file, not in scope)
Java Code:
public class theClass
{
	public theClass()
	{
		System.out.println("From theClass: Hello World!");
		System.out.println("From theClass: " + System.getProperty("java.io.tmpdir"));
	}
}
Error/output code:
Java Code:
From theClass: Hello World!
java.security.AccessControlException: access denied (java.util.PropertyPermission java.io.tmpdir read)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
	at java.security.AccessController.checkPermission(AccessController.java:553)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
	at java.lang.System.getProperty(System.java:669)
	at theClass.<init>(theClass.java:7)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
	at java.lang.Class.newInstance0(Class.java:372)
	at java.lang.Class.newInstance(Class.java:325)
	at loader.init(loader.java:21)
	at sun.applet.AppletPanel.run(AppletPanel.java:436)
	at java.lang.Thread.run(Thread.java:636)