Jump to content

Saving and Loading Data to getDirectoryData


Optimum Scripts

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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