Skip to content

BinaryExporter fails when serializing multiple UserData objects containing lists #2609

@riccardobl

Description

@riccardobl

I was playing around with @copilot and it says it found this issue: #2607 (comment)

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:

  1. Set testLists=true in jme3-plugins/src/test/java/com/jme3/export/JmeExporterTest.java (line 142)
  2. Run ./gradlew :jme3-plugins:test --tests "com.jme3.export.JmeExporterTest"
  3. 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

Metadata

Metadata

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions