Jump to content

Saving and Loading Data to getDirectoryData


Recommended Posts

Posted (edited)

I am getting an error when i try to save to: access denied ("java.lang.reflect.ReflectPermission" "suppressAccessChecks")

	public void saveUserProfiles(Script script) 
	{
		try 
		{
			FileOutputStream fileOut = new FileOutputStream(script.getDirectoryData() + USER_FILE);
			PrintStream printStream = new PrintStream(fileOut);
			fileOut.close();
			printStream.print(json.toJson(profiles));
			printStream.close();
		}
		catch (Exception e) 
		{
			script.logger.debug(e.getMessage());
		}
	}
	/**
	 * The user profiles file
	 */
	public static final String USER_FILE = "user_profiles.dat";
Edited by Optimum Scripts
Posted

Does the error really belong to this code? Seems like you are using reflection...

I doubt that is has anything to do with this code.

 

If you mean reflection client mode, I've tried both clients

My guess is that you're using an external library to parse JSON? And that library probably uses reflection, which requires the -allow reflection argument when opening the client.

But if this is the case, ext. libraries aren't copied to the SDN regardless

 

Actually i'm using GSON's original source code within my application, no library. But all json is doing is parsing the object, not writing the file

Posted

If you mean reflection client mode, I've tried both clients

 

Actually i'm using GSON's original source code within my application, no library. But all json is doing is parsing the object, not writing the file

 

GSON probably uses reflection somewhere, even if you dont use that particular method, if the classloader sees that any of your classes use it, it will act up.

 

  • Like 2
Posted (edited)

Had to resort to serializeable objects sad.png

 

That won't fly with the SDN either. Method names and class members have their identifiers changed by the obfuscator (including serialVersionUID)

In other words, you wont be able to load objects serialized by an earlier osbot client version

Edited by FrostBug

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...