jMonkeyEngine / jMonkeyEngine/jmonkeyengine

BinaryExporter fails when serializing multiple UserData objects containing lists

Open
#2,609 1 comment 2 reactions 2 assignees View on GitHub

@riccardobl is already working on this.

Since Feb 11, 2026.

Needs investigation
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:

  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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.