Hi all,
I have a class the contains a list of classes objects that themself contains list.
I try to save or load it using RandomAccessFile. Saving is ok (and there seems to be a file with things in it), but loading is crashing.
There must be something wrong as I thought that with RandomAccessFile I did not had to care with the object types when saving/loading, may be it's not handling list that contains objects themselves with lists ...
Any idea, advice to find the root cause ?
My class looks like what is below:
The log is:
I have a class the contains a list of classes objects that themself contains list.
I try to save or load it using RandomAccessFile. Saving is ok (and there seems to be a file with things in it), but loading is crashing.
There must be something wrong as I thought that with RandomAccessFile I did not had to care with the object types when saving/loading, may be it's not handling list that contains objects themselves with lists ...
Any idea, advice to find the root cause ?
My class looks like what is below:
B4X:
Sub Class_Globals
Dim Topics As List
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
Topics.Initialize
End Sub
Public Sub Save()
Dim raf As RandomAccessFile
raf.Initialize(Utils.thePath, "Data.txt", False)
raf.WriteObject(Topics, True, raf.CurrentPosition)
raf.Close
End Sub
Public Sub Load()
Dim raf As RandomAccessFile
raf.Initialize(Utils.thePath, "Data.txt", True)
Topics=raf.ReadObject(raf.CurrentPosition)
raf.Close
End Sub
The log is:
B4X:
Topics=raf.ReadObject(raf.CurrentPosition)
java.lang.IllegalArgumentException: invalid value for field
at java.lang.reflect.Field.setField(Native Method)
at java.lang.reflect.Field.set(Field.java:588)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readType(RandomAccessFile.java:500)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readObject(RandomAccessFile.java:476)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readList(RandomAccessFile.java:579)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readObject(RandomAccessFile.java:467)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readMap(RandomAccessFile.java:528)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readType(RandomAccessFile.java:495)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readObject(RandomAccessFile.java:476)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readList(RandomAccessFile.java:579)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readObject(RandomAccessFile.java:467)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readHelper(RandomAccessFile.java:401)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadObject(RandomAccessFile.java:362)
at com.test.testApp.test._load(test.java:71)