Optimum Scripts Posted June 21, 2016 Posted June 21, 2016 (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 June 21, 2016 by Optimum Scripts
Khaleesi Posted June 22, 2016 Posted June 22, 2016 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.
FrostBug Posted June 22, 2016 Posted June 22, 2016 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
Optimum Scripts Posted June 22, 2016 Author Posted June 22, 2016 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
FrostBug Posted June 22, 2016 Posted June 22, 2016 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. 2
Optimum Scripts Posted June 22, 2016 Author Posted June 22, 2016 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. Had to resort to serializeable objects
FrostBug Posted June 22, 2016 Posted June 22, 2016 (edited) Had to resort to serializeable objects 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 June 22, 2016 by FrostBug
Optimum Scripts Posted June 22, 2016 Author Posted June 22, 2016 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 Any recommendations ?
FrostBug Posted June 22, 2016 Posted June 22, 2016 Any recommendations ? Well, there aren't rly many good options left. I personally made some API around java 'Properties'