chen870647924 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Optional is not GWT-serializable #876

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Optional is annotated with @GwtCompatible, but when trying to compile for 
serialization over GWT-RPC of objects with Optional fields, I receive errors as 
below. This is using GWT 2.4.0 and Guava 11.0.1

[ERROR] com.google.common.base.Optional.Absent is not accessible from a class 
in its same package; it will be excluded from the set of serializable types 
(reached via [redacted])
 [ERROR] com.google.common.base.Optional.Present<T> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via [redacted])
 [ERROR] com.google.common.base.Optional<T> has no available instantiable subtypes. (reached via [redacted])
    [ERROR]    subtype com.google.common.base.Optional<T> is not instantiable
    [ERROR]    subtype com.google.common.base.Optional.Present<T> is not default instantiable (it must have a zero-argument constructor or no constructors at all) and has no custom serializer. (reached via [redacted])
    [ERROR]    subtype com.google.common.base.Optional.Absent is not accessible from a class in its same package; it will be excluded from the set of serializable types (reached via [redacted])

Original issue reported on code.google.com by raymond....@gmail.com on 20 Jan 2012 at 2:40

GoogleCodeExporter commented 9 years ago
We'll need to add a _CustomFieldSerializer.

Original comment by cpov...@google.com on 20 Jan 2012 at 3:45

GoogleCodeExporter commented 9 years ago
Fixed internally.  Will be mirrored out within the next few days.

FYI, we annotate GWT-serializable classes with "@GwtCompatible(emulated = 
true)," so the failure to serialize Optional was expected.  That said, do 
continue to request classes that you would like to see made serializable.

Original comment by cpov...@google.com on 27 Jan 2012 at 5:24

GoogleCodeExporter commented 9 years ago
Thanks for the fix as well as the explanation--that is helpful to know.

Original comment by raymond....@gmail.com on 27 Jan 2012 at 5:30

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:14

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08