Is there a way to completely disable Java Security Manager?
I am experimenting with db4o source code. It uses reflection to save objects, and it seems that the security manager does not allow to read and write private or protected fields.
My code is:
public static void main(String[] args) throws IOException { System.out.println("start"); new File( DB_FILE_NAME ).delete(); ObjectContainer container = Db4o.openFile( DB_FILE_NAME ); String ob = new String( "test" ); container.store( ob ); ObjectSet result = container.queryByExample( String.class ); System.out.println( "retrieved (" + result.size() + "):" ); while( result.hasNext() ) { System.out.println( result.next() ); } container.close(); System.out.println("finish"); }
Output:
start
[db4o 7.4.68.12069 2009-04-18 00:21:30]
AccessibleObject # setAccessible () is not available. Private fields can not be stored.
retrieved (0):
finish
This thread suggests modifying the java.policy file so that it can reflect, but it doesn't seem to work for me.
I start the JVM with the arguments -Djava.security.manager -Djava.security.policy==/home/pablo/.java.policy
therefore, the specified policy file will be the only policy file used
The file is as follows:
grant {
permission java.security.AllPermission;
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};
I spent the last 3 hours on this, and I have no idea how to do this. Any help was appreciated.
java reflection security db4o
Pawel Piatkowski Apr 17 '09 at 10:40 2009-04-17 22:40
source share