Bugs to fix for Binary import/export

I exported a node with a geosphere attached to it, very simple with no renderstates or anything else. It will never load back.



Here's the stack trace:



Oct 27, 2007 4:22:02 PM class com.jme.util.export.binary.BinaryImporter readObject(int id)
SEVERE: Exception
java.lang.InstantiationException: com.jme.scene.shape.GeoSphere
   at java.lang.Class.newInstance0(Class.java:340)
   at java.lang.Class.newInstance(Class.java:308)
   at com.jme.util.export.binary.BinaryClassLoader.fromName(Unknown Source)
   at com.jme.util.export.binary.BinaryImporter.readObject(Unknown Source)
   at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(Unknown Source)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(Unknown Source)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(Unknown Source)
   at com.jme.scene.Node.read(Unknown Source)
   at com.jme.util.export.binary.BinaryImporter.readObject(Unknown Source)
   at com.jme.util.export.binary.BinaryImporter.load(Unknown Source)
   at com.jme.util.export.binary.BinaryImporter.load(Unknown Source)
   at com.jme.util.export.binary.BinaryImporter.load(Unknown Source)



Not sure what other information would be helpful.

Does GeoSphere have a constructor with no arguments?

it didn't until now

Ah, I didn't know we had a Geosphere, I thought it was a custom class.



So update from CVS and try again nymon.

Perfect. And once again, thanks for the timely response.  :slight_smile:

After further testing and confirmation by glancing at the source, both Hexagon and RoundedBox suffer from the lack of an empty constructor as well.



Dodecahedron, Icasohedron and Octahedron don't load back either:


java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Integer
   at com.jme.util.export.binary.BinaryInputCapsule.readInt(Unknown Source)
   at com.jme.scene.shape.Dodecahedron.read(Unknown Source)


Those seem simple enough to fix, theres only one line in the read and write methods.

After these, every shape has been tested and saves/loads without problems.

I'm so accustomed to quick responses, I'm afraid this one may have slipped through the cracks. Don't forget me!

It's fixed in cvs - thanks for finding those, nymon.

Hello. Old post, buy anyway:

I still have problem with RoundedBox, still get ClassCastException. I checked and RoundedBox really doesn't have empty constructor, so I think not a problem to quickly fix it… :slight_smile:

Why don't you try adding an empty constructor and see if it fixes the problem?

Tried it, and it fixes the problem.

Actually I added:


    public RoundedBox()
    {
       this("Some rounded box");
    }


The only thing that matters is, that the object which implements Savable, has a constructor with no arguments.
There is also another way of doing this, but involves writing special modules for BinaryClassLoader (example for this can be found in jME Physics, where you have to write: getPhysicsSpace().setupBinaryClassLoader(BinaryImporter.getInstance()); if you want to load physics classes from binary jme file.
Anyway, I think that more appropriate way is the first one, since all the basic bodies support it...

actually you should just write super(); instead of using the this() constructor taking a name, as that one is for initializing an object inside the code, not through serialization.