Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
JME serialization does not work with protected/private constructors #1119
We should fix JME serialization to work with protected/private constructors. Of course, that probably requires special dispensation in Java 11.
We just have to use reflection to grab the no-arg constructor and make setAccessible(true) or whatever.
Links to the forum page in case:
What, in general, would a fix here look like?
The serialisation schemes that I've run across generally do require a public, no-arg constructor. Otherwise, you're playing monkey-games with Reflection.
Or are you just running into cases where the class was inappropriately built with private constructors?
The fix would look like playing games with reflection. Games are already being played with reflection to access private fields, etc. in the SpiderMonkey serialization.
We require no-arg constructors but often it makes the classes themselves very fragile to have public no-arg constructors. Any time you see "Provided for serialization, do not call" as a javadoc comment on a public constructor we should feel sad.... there's no reason for it.