mardi 1 mars 2016

Reflection AccessControlException

In my custom dataset, I'm using a constructor in the RMI Server to create a new instance of my class.

Constructor<?> constructor = dynTable.getDeclaredConstructor(Class.class);
constructor.setAccessible(true); // <-- Exception here
... = constructor.newInstance(type);
constructor.setAccessible(false);

However, if I set a SecurityManager, it throws the expection below.

java.security.AccessControlException: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
    at java.security.AccessController.checkPermission(AccessController.java:884)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:128)
    at net.sviglas.meridian.task.DefaultDatasetConstructor$1.constructDataset(DefaultDatasetConstructor.java:45)
...

The policy file for both the server and the client:

grant {
    permission java.security.AllPermission;
};

I gave permission for everything but I'm still getting this security exception. Do you know why?





Aucun commentaire:

Enregistrer un commentaire