[Solved] Problem reading savableArrayList

Hi,

this should be rather simple. But I think I’m doing something wrong now. I save and load a savable like this:

   @Override
   public void write(JmeExporter ex) throws IOException {
        OutputCapsule out = ex.getCapsule(this);
        out.writeSavableArrayList((ArrayList) entries, "entries", null);
    }

    @Override
    public void read(JmeImporter im) throws IOException {
        InputCapsule in = im.getCapsule(this);
        in.readSavableArrayList("entries", null);
    }

Whereas the entries field is:

private List<CameraSweepDataEntry> entries;

CameraSweepDataEntry implements Savable. And as far as I read the files with an hex editor. I can see the data there. But when I load them, the entries get null. I don’t know what is wrong…

The loading is initialized by a:

public class CameraSweepDataLoader implements AssetLoader {

    public static final String CAMERA_SWEEP_DATA_FILE_EXTENSION = "csd";

    @Override
    public Object load(AssetInfo assetInfo) throws IOException {
        BinaryImporter importer = BinaryImporter.getInstance();
        return importer.load(assetInfo);
    }

Edit: Oops, what I posted before was wrong.

Are you sure that when you save the data its actually available?

Yes quite sure. The produced files do contain data. And are of variable lengths, so something is going in. And I did debug it and the exporter was holding the data. But the importer doesn’t seem to contain these as far as I can tell.

Ofcourse its null, where are you actually using the entries variable in the load code?

1 Like

Oh snap. Fug, feeling retarded now. I kinda thought it was using reflection, but… Yes, the return value. Needs. To. Be. Assigned… Thank you and so sorry…

You’re welcome! It’s sometimes the simplest things that make hard to find bugs, there’s no need to feel bad for that.

1 Like