[committed] Missing "isCollidable" in Spatial.write()

Hi everyone



I noticed that in the write() method of Spatial the key "isCollidable" is never written into the capsule, but

this key is read in the read() method. I'm refering to r4640.

By adding this:


capsule.write(isCollidable(1), "isCollidable", true);


in the write() method it should be ok. I tested this (with CloneImportExport) and it worked fine. Of course
the "true" (and maybe the "1"?) value could be changed.
I think the last commit just forgot that, small issue.
Bye

Wasserleiche

nice catch

Since I have no permissions to commit into the JME2-SVN, someone else should commit this one-line fix. I'm sure

there can be found some volunteer :D.

Wasserleiche said:

Since I have no permissions to commit into the JME2-SVN, someone else should commit this one-line fix. I'm sure
there can be found some volunteer :D.


24 hours from the time you post ;)  Gotta give people time to take a look
sbook said:

24 hours from the time you post ;)  Gotta give people time to take a look


Sure, I just wanted to mention that I cannot commit it by myself, thats all :)

Ok, but why did I get this Runtime-Exception:



java.lang.RuntimeException: java.lang.NullPointerException

at com.jme.util.CloneImportExport.load(CloneImportExport.java:251)

at com.jme.util.CloneImportExport.loadClone(CloneImportExport.java:304)

        …



If Ilook at line 251 in CloneImportExport and insert e.printStackTrace(); before the RTE is thrown,

I get this:

java.lang.NullPointerException

at com.jme.util.CloneImportExport$CloneCapsule.readBoolean(CloneImportExport.java:820)

at com.jme.scene.Spatial.read(Spatial.java:1124)

at com.jme.scene.Node.read(Node.java:682)

at com.jme.util.CloneImportExport.load(CloneImportExport.java:246)

at com.jme.util.CloneImportExport.loadClone(CloneImportExport.java:305)

        …



I inserted System.out.println(name); in line 819 at CloneImportExport in the readBoolean() method. As I

try again, the last printout before the exception is "isCollidable". So obviously it is trying to read it, but it's

never writen? When I write isCollidable in Spatial.write(), this does not happen anymore.

I honestly do not understand what you did with the whole savable-spatial-thing, but this needs to be fixed

somehow ^^.

I hope it's clear how my bug-hunting worked :wink:

Bye



Wasserleiche

Wasserleiche said:

Ok, but why did I get this Runtime-Exception:

java.lang.RuntimeException: java.lang.NullPointerException
at com.jme.util.CloneImportExport.load(CloneImportExport.java:251)
at com.jme.util.CloneImportExport.loadClone(CloneImportExport.java:304)
       ...

If Ilook at line 251 in CloneImportExport and insert e.printStackTrace(); before the RTE is thrown,
I get this:
java.lang.NullPointerException
at com.jme.util.CloneImportExport$CloneCapsule.readBoolean(CloneImportExport.java:820)
at com.jme.scene.Spatial.read(Spatial.java:1124)
at com.jme.scene.Node.read(Node.java:682)
at com.jme.util.CloneImportExport.load(CloneImportExport.java:246)
at com.jme.util.CloneImportExport.loadClone(CloneImportExport.java:305)
       ...

I inserted System.out.println(name); in line 819 at CloneImportExport in the readBoolean() method. As I
try again, the last printout before the exception is "isCollidable". So obviously it is trying to read it, but it's
never writen? When I write isCollidable in Spatial.write(), this does not happen anymore.
I honestly do not understand what you did with the whole savable-spatial-thing, but this needs to be fixed
somehow ^^.
I hope it's clear how my bug-hunting worked ;)
Bye

Wasserleiche


Ok.  Thanks for the details.

Looks like there's a bug in CloneImportExport$CloneCapsule.  The indicated method (CloneImportExport$CloneCapsule.readBoolean) should never throw NPE regardless of input.

Are you using X3dToJme?  That seems to be the only class that uses the CloneImportExport class.  If yes, then I'll try to reproduce with the simpleScene.x3d file in the code base.  If I can't, could you upload a model file that exhibits the problem to somewhere I can get it?

The reported line number doesn't make sense with the contents of CloneImportExport.java.  Could you please revert the contents of that file to match svn HEAD, rebuild, reproduce the problem, and post that stack trace?

Thanks for you responds!



I do not use X3dToJme, I import *.obj-files (created with misfit model 3D g). You can get such a

model here: http://infinitewars.svn.sourceforge.net/viewvc/infinitewars/data/models/neutralSpawnStation/high/



To import this, I use this file: [ur]http://infinitewars.svn.sourceforge.net/viewvc/infinitewars/src/fileHandling/ModelImporter.java?revision=425&view=markup[/url]

The method of interest is getModel(). The whole project is open source, so you can look around, of course g.



Here is the complete stack trace of the exception:



01.09.2009 17:15:49 class com.jme.util.GameTask invoke()

SCHWERWIEGEND: Exception

java.lang.RuntimeException: java.lang.NullPointerException

at com.jme.util.CloneImportExport.load(CloneImportExport.java:251)

at com.jme.util.CloneImportExport.loadClone(CloneImportExport.java:304)

at fileHandling.ModelImporter.getLoadedNode(ModelImporter.java:44)

at fileHandling.ModelImporter.getModel(ModelImporter.java:62)

at fileHandling.ModelImporter.getModel(ModelImporter.java:113)

at scenario.MatchScenario.generateSpawns(MatchScenario.java:65)

at main.MatchLoadingProcess.nextStep(MatchLoadingProcess.java:56)

at main.LoadingThread.call(LoadingThread.java:23)

at main.LoadingThread.call(LoadingThread.java:1)

at com.jme.util.GameTask.invoke(GameTask.java:140)

at com.jme.util.GameTaskQueue.execute(GameTaskQueue.java:111)

at com.jmex.game.StandardGame.update(StandardGame.java:378)

at com.jmex.game.StandardGame.run(StandardGame.java:250)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NullPointerException

at com.jme.util.CloneImportExport$CloneCapsule.readBoolean(CloneImportExport.java:819)

at com.jme.scene.Spatial.read(Spatial.java:1124)

at com.jme.scene.Node.read(Node.java:682)

at com.jme.util.CloneImportExport.load(CloneImportExport.java:246)

… 13 more



I will try to make a small program to reproduce it, but maybe the things above can help you, too

Bye



Wasserleiche

Wasserleiche said:

Thanks for you responds!

I do not use X3dToJme...

Wasserleiche


It's great to have your help making a test case, because my attempts to reproduce so far have been unsuccessful.

It might have something to do with my model-loading-methods in ModelImporter (at my project). Maybe

you could take a look there. The whole loading-thing is just glued together so it works somehow, I never

really got into it ^^.

Bye



Wasserleiche

Wasserleiche said:

It might have something to do with my model-loading-methods in ModelImporter (at my project). Maybe
you could take a look there. The whole loading-thing is just glued together so it works somehow, I never
really got into it ^^.
Bye

Wasserleiche


That explains a lot (I mean wrt figuring out how the CloneImportExport class got involved).

I think I see the bug in CloneImportExport$CloneCapsule.readBoolean().  Autoboxing makes these kind of NPEs difficult to recognize.  If I post a tiny patch here or PM it to you, could you apply it to the jME HEAD version of CloneImportExport.java and retry?



UPDATE:  I went ahead and applied the fix with rev 4649, because even if it does not fix your issue (which it probably will), the coding for supporting the 'defVal' parameter was definitely incomplete.

Thank god, it works now.

But there is another RTE:



01.09.2009 19:22:04 com.jmex.game.DefaultUncaughtExceptionHandler uncaughtException

SCHWERWIEGEND: Main game loop broken by uncaught exception

java.lang.RuntimeException: java.lang.NullPointerException

at com.jme.util.CloneImportExport.load(CloneImportExport.java:252)

at com.jme.util.CloneImportExport.loadClone(CloneImportExport.java:305)

at fileHandling.ModelImporter.getLoadedNode(ModelImporter.java:44)

at fileHandling.ModelImporter.getModel(ModelImporter.java:62)

at fileHandling.ModelImporter.getModel(ModelImporter.java:113)

at logic.nodes.ModelNode.updateModelGeometry(ModelNode.java:76)

at logic.nodes.ModelNode.updateGeometryQuality(ModelNode.java:58)

at gameStates.IngameState.updateGraphicSettings(IngameState.java:161)

at gameStates.IngameState.updateGraphicSettings(IngameState.java:146)

at gameStates.IngameState.restore(IngameState.java:227)

at gameStates.MatchState.restore(MatchState.java:445)

at main.InitGame.changeGraphicSettings(InitGame.java:281)

at interfaces.menu.options.GraphicOptionsWindow$1.buttonPressed(GraphicOptionsWindow.java:43)

at org.fenggui.Button.fireButtonPressedEvent(Button.java:237)

at org.fenggui.Button.released(Button.java:164)

at org.fenggui.Button.access$1(Button.java:159)

at org.fenggui.Button$8.mouseReleased(Button.java:208)

at org.fenggui.ObservableWidget.mouseReleased(ObservableWidget.java:353)

at org.fenggui.Display.fireMouseReleasedEvent(Display.java:410)

at input.FengJMEInputHandler$MouseListener.onButton(FengJMEInputHandler.java:184)

at com.jme.input.lwjgl.LWJGLMouseInput.update(LWJGLMouseInput.java:233)

at com.jme.input.InputSystem.update(InputSystem.java:67)

at com.jmex.game.StandardGame.run(StandardGame.java:248)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NullPointerException

at com.jme.util.CloneImportExport$CloneCapsule.readInt(CloneImportExport.java:1186)

at com.jme.scene.state.TextureState.read(TextureState.java:777)

at com.jme.util.CloneImportExport$CloneCapsule.readSavableArray(CloneImportExport.java:1383)

at com.jme.scene.Spatial.read(Spatial.java:1148)

at com.jme.scene.Geometry.read(Geometry.java:908)

at com.jme.scene.TriMesh.read(TriMesh.java:642)

at com.jme.util.CloneImportExport$CloneCapsule.readSavableArrayList(CloneImportExport.java:1454)

at com.jme.scene.Node.read(Node.java:683)

at com.jme.util.CloneImportExport.load(CloneImportExport.java:247)

… 23 more



This time its readInt(), so maybe it's a similiar issue. Maybe you can also take a look there, since I

have no idea whats going on there ^^.

Thanks for the help, I think all users benefit from this :slight_smile:

Bye



Wasserleiche

Wasserleiche said:

Thank god, it works now.
But there is another RTE:

01.09.2009 19:22:04 com.jmex.game.DefaultUncaughtExceptionHandler uncaughtException
SCHWERWIEGEND: Main game loop broken by uncaught exception
java.lang.RuntimeException: java.lang.NullPointerException
at com.jme.util.CloneImportExport.load(CloneImportExport.java:252)
...
at com.jme.util.CloneImportExport.load(CloneImportExport.java:247)
... 23 more

This time its readInt(), so maybe it's a similiar issue. Maybe you can also take a look there, since I
have no idea whats going on there ^^.
Thanks for the help, I think all users benefit from this :)
Bye

Wasserleiche


Yes, very likely the same exact problem.  I fixed about 12 occurrences of this same oversight in an XMLImporter-related class a few months back.  I have to work on my own problems now, but will look into this later on today.

I added default proper default handling for all types except for the newish Savable Maps (which requires independent consideration).



Rev. 4651.  Please retry.

It works fine now, I get no more RTE. Nice work :smiley:

Should I change the thread-title into [commited]?

Wasserleiche said:

It works fine now, I get no more RTE. Nice work :D
Should I change the thread-title into [commited]?


Thanks.

Sounds like a good idea.