Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set, ArrayList, Map break deserialization #12

Open
Bellski opened this issue Aug 18, 2019 · 2 comments
Open

Set, ArrayList, Map break deserialization #12

Bellski opened this issue Aug 18, 2019 · 2 comments
Milestone

Comments

@Bellski
Copy link

Bellski commented Aug 18, 2019

seems problem with generics for Set, ArrayList, Map.

try to change ArrayList on List and it will work

repo for reproduce:

https://github.com/Bellski/rpc

@niloc132
Copy link
Member

This is a bug I encountered early on, and apparently forgot about: old GWT-RPC had specific changes made to the JRE emulation so that there was always a serializable field to represent the data which needed to be serialized. In contrast, the JRE's actual implementation marks the actual storage of the data as transient, as if it were never to be serialized, and then goes on to implement readObject/writeObject, which we're unable to use (two reasons: they have to be called through reflection since their are private, and they don't inform us of the type information at compile time, but just assume that any type is serializable).

Instead of a readObject/writeObject, this project uses the CustomFieldSerializer mechanism to say how to serialize at runtime for those types. Additionally, we need a mechanism (probably attached to that class, perhaps through an annotation?) to statically list how to know what extra types - especially generic ones - need to be marked as serializable and traversed at compile time.

@niloc132 niloc132 added this to the 1.0 milestone Oct 5, 2019
@niloc132
Copy link
Member

Plan:

Create a new annotation that will be put on a CustomFieldSerializer to indicate the Object types that this serializer will read/write to the stream. As an example, java.util.ArrayList<E> has a transient field of type E[], and the custom field serializer then should handle the 1st generic arg (and in the same way, HashMap<K,V> would mark both the 1st and 2nd arg as serializable). This can also solve a problem historically encountered when writing CustomFieldSerializer types: when a type needs to be serializable but isn't listed as a field, somewhere else that type needs to be manually whitelisted.

This annotation on CustomFieldSerializer types will either let the index of the generic arg on the original type be specified, or the fully qualified type. It may be possible to generalize the "qualified type name" (pre-publish edit: actually a class literal seems better) to also allow it to be parameterized, and possibly parameterized based on the generics of the serializable type itself, but this isn't a goal for this initial step (and isn't necessary to solve this particular bug).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants