zeroc-ice / ice

All-in-one solution for creating networked applications with RPC, pub/sub, server deployment, and more.
https://zeroc.com
GNU General Public License v2.0
2k stars 592 forks source link

Update 'serialVersionUID' Fields in Java #2309

Closed InsertCreativityHere closed 2 weeks ago

InsertCreativityHere commented 2 weeks ago

This PR is the 2nd half in implementing #283 (following after #2307). It updates all of the serialVersionUID fields we have in the non-generated code.

1) There were some classes that weren't even serializable which had this field... so I deleted the field there. 2) There were some places where we were setting a UID of 0, presumably out of laziness. These were updated with real values. An exception to this is abstract classes; abstract classes can never be serialized (since they cannot be instantiated), but it's still seen as good practice to provide a UID, so for those classes, I left the value of 0 alone. It's fine. 3) All of the fields were made private instead of public.


For future people

The JDK includes a tool for computing these UIDs, which can be invoked as follows:

PS D:\ice\java> serialver -classpath "src\Ice\build\classes\java\main" com.zeroc.Ice.UnknownSlicedValue
com.zeroc.Ice.UnknownSlicedValue:    private static final long serialVersionUID = -3199177633147630863L;

and will also inform you when the field shouldn't be present:

PS D:\ice\java> serialver -classpath "src\Ice\build\classes\java\main" com.zeroc.Ice.OpaqueEndpointInfo
Class com.zeroc.Ice.OpaqueEndpointInfo is not Serializable.

Theoretically, whenever we update the fields of a serializable class, we should be re-computing it's serialVersionUID.