jMonkeyEngine / jMonkeyEngine/jmonkeyengine
BinaryExporter fails when serializing multiple UserData objects containing lists
@riccardobl is already working on this.
Since Feb 11, 2026.
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 14
Description
I was playing around with @copilot and it says it found this issue: https://github.com/jMonkeyEngine/jmonkeyengine/pull/2607#issuecomment-3887504117
Reporting here for tracking, but i haven't validated it yet.
When a Spatial has multiple UserData entries containing lists (e.g., "int-list", "string-list", "float-list"), the BinaryExporter/BinaryImporter fails to deserialize correctly. The first list in the userData HashMap deserializes successfully, but subsequent lists return null and cause an ArrayIndexOutOfBoundsException during deserialization.
Steps to reproduce:
- Set
testLists=trueinjme3-plugins/src/test/java/com/jme3/export/JmeExporterTest.java(line 142) - Run
./gradlew :jme3-plugins:test --tests "com.jme3.export.JmeExporterTest" - Observe that BinaryImporter (Node 1) returns null for int-list and string-list, while float-list works (being first in iteration order)
Error:
java.lang.ArrayIndexOutOfBoundsException: Index -3 out of bounds for length 4
at com.jme3.export.binary.ByteUtils.rightAlignBytes(ByteUtils.java:554)
at com.jme3.export.binary.BinaryInputCapsule.readInt(BinaryInputCapsule.java:834)
at com.jme3.export.binary.BinaryInputCapsule.setContent(BinaryInputCapsule.java:154)
Notes:
- XMLExporter/XMLImporter works correctly with all lists
- Only affects BinaryExporter when multiple UserData objects with lists exist
- Appears to be a byte stream alignment issue in the binary format
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.