
google-web-toolkit - issue #7331
CustomFieldSerializer implementations must implement de/serialization and instantiation methods twice
(GWT 2.4.0. In GWT compile step, not platform-specific.)
Use of a CustomFieldSerializer requires both abstract instance methods AND static methods to be implemented for serialize and deserialize. Need the abstract methods in order to extend CustomFieldSerializer, but com.google.gwt.user.rebind.rpc.CustomFieldSerializerValidator requires the static methods at runtime, throwing exceptions like the following if they're missing:
Custom Field Serializer 'Xxx_CustomFieldSerializer' does not define a deserialize method: 'public static void deserialize(SerializationStreamReader reader,Xxx instance)' (reached via Xxx)
Having to write all of these static methods means that you can't extract boiler plate for similarly serialized objects. This means that a simple such class goes from about four lines to about 15. There are good examples of this inside GWT, for example HashMap_CustomFieldSerializer and friends all refer to a common Map_CustomFieldSerializerBase helper class:
To fix: Methods on CustomFieldSerializerValidator like getDeserializationMethod should be able to return the instance method rather than the static one, and shouldn't require the static ones to exist.
See also this Stack Overflow question: http://stackoverflow.com/questions/10249093/why-does-a-customfieldserializer-need-static-methods
Comment #1
Posted on Nov 12, 2012 by Grumpy ElephantWould be nice to have this fixed in the documentation too as it doesn't mention the static methods:
It is, of course, possible to work out what needs to be done but the documentation should be more complete (considering that if you only do what it says you get compile errors...).
Comment #2
Posted on May 29, 2013 by Quick OxIt works just fine if you only create the static methods and not implement the interface (which is how custom field serializers used to work before). So the documentation is wrong or the code that goes with the documentation was never committed ?
Comment #3
Posted on May 29, 2013 by Swift RhinoThe doc should be fixed.
The CustomFieldSerializer abstract class is there to give a performance boost on the server-side (see r9592). Client-side code still depends on the static methods.
Comment #4
Posted on Sep 9, 2013 by Swift Rhino(No comment was entered for this change.)
Comment #5
Posted on Jun 10, 2015 by Massive CatIssue tracked moved to github, see https://github.com/gwtproject/gwt/issues
Status: MovedToGithub
Labels:
Category-Website