Hi Stuart,

Unfortunately, several Java SE interfaces have public SVUIDs, so the fix can 
cause confusion:

$ serialver java.security.PublicKey
java.security.PublicKey:    private static final long serialVersionUID = 
7187392471159151072L;

$ javap java.security.PublicKey
Compiled from "PublicKey.java"
public interface java.security.PublicKey extends java.security.Key {
  public static final long serialVersionUID;
}

Thanks,
-Yuri

-----Original Message-----
From: core-libs-dev-boun...@openjdk.java.net 
[mailto:core-libs-dev-boun...@openjdk.java.net] On Behalf Of Stuart Marks
Sent: Friday, November 8, 2013 7:03 AM
To: core-libs-dev
Subject: RFR: 8028027: serialver should emit declaration with the 'private' 
modifier

Hi all,

Please review this quick one-liner to change the serialver tool so that it 
emits a serialVersionUID declaration with the 'private' modifier, which 
comports with the recommendation in the java.io.Serializable page.

Bug:

     https://bugs.openjdk.java.net/browse/JDK-8028027

Patch appended below.

Thanks,

s'marks


----------


# HG changeset patch
# User smarks
# Date 1383868023 28800
# Node ID 1e1088bfea50d7d3cc7cfdce2b0085b7adc6a180
# Parent  f18b60bd22a1be988d329960c46d504f4b75000f
8028027: serialver should emit declaration with the 'private' modifier
Reviewed-by: XXX

diff -r f18b60bd22a1 -r 1e1088bfea50
src/share/classes/sun/tools/serialver/SerialVer.java
--- a/src/share/classes/sun/tools/serialver/SerialVer.java      Thu Nov 07 
15:45:21 
2013 -0800
+++ b/src/share/classes/sun/tools/serialver/SerialVer.java      Thu Nov 07 
15:47:03 
2013 -0800
@@ -211,7 +211,7 @@
          Class<?> cl = Class.forName(classname, false, loader);
          ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
          if (desc != null) {
-            return "    static final long serialVersionUID = " +
+            return "    private static final long serialVersionUID = " +
                  desc.getSerialVersionUID() + "L;";
          } else {
              return null;

Reply via email to