Hello,

Another part of the cleanup of library serialization usage ahead of augmented javac -Xlint warnings (JDK-8160675), the non-serializable instance fields of serializable types in the java.prefs module should have their serial warnings suppressed. The analogous issue in core libs is JDK-8231202.

For the type in question, while NodeChangeEvent is typed as serializable, both its readObject and writeObject methods are written to unconditionally throw exceptions, so it is not serializable in practice. The class does define a serialVersionUID, so the one suspect field can be marked as "transient" without causing an effective change in serialization support.

Patch below.

Thanks,

-Joe

diff -r e23e560afbcb src/java.prefs/share/classes/java/util/prefs/NodeChangeEvent.java --- a/src/java.prefs/share/classes/java/util/prefs/NodeChangeEvent.java Wed Sep 25 21:26:38 2019 -0700 +++ b/src/java.prefs/share/classes/java/util/prefs/NodeChangeEvent.java Thu Sep 26 10:48:34 2019 -0700
@@ -49,7 +49,7 @@
      *
      * @serial
      */
-    private Preferences child;
+    private transient Preferences child;

     /**
      * Constructs a new {@code NodeChangeEvent} instance.


Reply via email to