Closed RogerRiggs closed 12 years ago
Email core libs when there's a format proposal.
Broaden the description to apply to serialization of all persistent classes; Previously only referred to the missing spec for TZ serialization.
Using a serialisation delegate, with a package scoped Ser class.
Implement the main package on a branch and then ask @RogerRiggs to get an internal Oracle reviewer
I have pushed a branch to https://github.com/RichardWarburton/threeten/tree/serialisation for @RogerRiggs to get an internal reviewer to look at. Overall process is documented in javadoc of javax.time.Ser.
Some comments.
Overall, I think this will produce effective and well-defined serialization forms.
Thanks for your comments Stephen, its pretty late my end so I'll fix those issues up tomorrow.
The enums approach runs under the assumption that the TCK will define an ordering for such classes.
I'll ask for more comments from other Oracle folks. Comments:
More later,
If the type byte is used for versioning then something (the type perhaps) will need to be passed to the read/writeExternal method so each class has enough information to deal with the data in the stream properly.
If new read/writeExternal methods would be needed then perhaps they should be named to include the version number so its clear what version of data they handle. Thanks to Brian G for his comments.
I'd note that the read/write external methods could all be moved to the Ser class. However, when I first came up with the pattern I found that using the current approach allowed better access to the internals of each class (less package scoped code).
Personally, I think that a version 2 of any of these specs is highly unlikely, as the state of the class pretty much defines the type, so any change to the state would need a different type.
While unlikely, it is prudent to make sure the versioning mechanism works before v2. The built-in serialization handles version skew in both directions since it must deal with older versions being able to interoperation with newer versions. It tolerates both adding fields and 'removing' fields. The stream protocol is robust in that it can handle missing and extra information without getting a stream corrupted error.
I've pushed updates to the branch in response to the feedback - see commit names for specifics - I think this fixes most raised issues.
git diff serialisation:src/main/java/javax/time/Period.java master:src/main/java/javax/time/Period.java
locallyI've pushed the necessary tests for the serialization format into this branch.
The handling of enum's is asymmetric. For each readExternal() method there should be a corresponding writeExternal(); adjecent in the code so it is easy to see they are complementary. Ser.writeInternal should call the Enum's writeExternal method and not shortcut it.
The usage of ZONE_ID_TYPE and ZONE_ID_FIXED_TYPE is matching implementation types not public types. That might be worthy of a comment. The names imply different types of ZoneId but the type is only used to reflect a customization serialization format that is more related to the implementation than the ZoneId.
Agreed to integrate Richard's code.
Is this integration still pending?
Yes. Not happened yet.
Merged branch (lots of git pain). Removed special enum handling. Simplified ZoneId handling. Regenerated bin files.
The serialization format of all JSR 310 classes. Ser needs to be documented as part of the spec.