Additional -Xlint:serial warning

Jonathan Gibbons jonathan.gibbons at oracle.com
Mon Aug 30 19:21:54 PDT 2010


On 08/04/2010 04:50 AM, Florian Weimer wrote:
> The JLS does not provide binary compatibility for compiler-generated
> fields (such as reference to an outer class object from an inner class
> object).  This means that there is no reliable way to use such classes
> in serialization even if all involved classes implement
> java.io.Serializable.  A mere recompilation of unchanged sources might
> result in different compiler-generated names.
>
> Would it make sense to enhance -Xlint:serial to warn about classes
> which implement java.io.Serializable and contain compiler-generated
> fields?
>
> PS: This is quite different from the frequently observed issue where a
> non-static inner class cannot be serialized because the outer class is
> not serializable.  Serialization works fine, but deserialization
> silently results in invalid objects.
>
>    

Filed as issue 6981095, it should be visible on bugs.sun.com in the next 
few days.

-- Jon



More information about the compiler-dev mailing list