I have the following scenario: I export a custom Model class (which implements Savable) to a jME binary file. Everything works fine, it saves, it loads, perfect. I do this from a custom ModelViewer tool. This tool saves the custom Model class (including another custom controller class) containing real class names. Lets say the class name for my Model class is com.example.Model.
Now my problem is, that the game which is supposed to load the exported Model cannot load it if the game's classes are obfuscated. After obfuscation, there is no longer a com.example.Model class, it might be a.b.C or anything else.
Is there a way to tell the BinaryImporter that com.example.Model now is a.b.C ? This is also interesting after a refactoring (which also happened to me), lets say I refactor com.example.Model to de.example.Model after hundreds of binary files have been saved over months of work with the old name. It would be very convenient to just tell the BinaryImport: hey if you encounter any com.example.Model, it's now called de.example.Model, use this class name instead!
I tried to answer this question myself but got confused while looking through the code of the binary package classes. So I ask the pros
Thanks very much!!
Yes, you can subclass BinaryImporter overwrite readObject(int id) and the first time it is invoked you can iterate through the 'classes' field and replace all 'className' fields of the BinaryClassObjects in there…
I'll have a look at this, thanks!