Skip to content

Geoposition is not seralizable but claims it is (because BodyTarget can't be serialized). #2448

@Dunbaratu

Description

@Dunbaratu

A GEOPOSITION Structure claims :ISSERIALIZABLE is true, meaning it can be used with READJSON() and WRITEJSON().
But this is false, as demonstrated below:

(Typed at the terminal interactive prompt)

set x to latlng(90,90).
print x:isserializable.
True
writejson(x, "some_file").  // allows you to write it
set y to readjson("some_file").   // but does not allow you to read it back.
Method not found: 'Default constructor not found.. ctor() of kOS.Suffixes.BodyTarget'.
at Interpreter line 7
set y to readjson("some_file").
         ^

For objects to be serializable, all the objects inside them that they save need to be serializable too. BodyTarget, which is saved as part of a GeoCoordinates, isn't serializable because it has no default constructor. (All serializable items need a default constructor because the way SafeSerializationMge.CreateInstance() works, it makes a dummy of the object first, then populates its fields from what's in the file. If it can't make the initial dummy of the object (no default constructor), then it can't do the work.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions