Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8209317

Deprecate serialVersionUID fields in interfaces

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 12
    • Component/s: security-libs
    • Labels:
      None
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Possibility of new warnings, but references to the serialVersionUID fields are unlikely.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Deprecate ineffectual serialVersionUID fields on various interface types in the security libraries and elsewhere.

      Problem

      Since the serialVersionUID in question are ineffectual, use of them is misleading and should be discouraged by deprecating the fields.

      Solution

      Deprecate the 20 ineffectual serialVersionUID fields. It is not necessary to deprecate them for removal.

      Specification

      Deprecate the following 20 serialVersionUID fields:

      --- old/src/java.base/share/classes/java/security/Key.java  2018-08-09 11:18:34.372000999 -0700
      +++ new/src/java.base/share/classes/java/security/Key.java  2018-08-09 11:18:34.228000999 -0700
      @@ -108,8 +108,12 @@
           * The class fingerprint that is set to indicate
           * serialization compatibility with a previous
           * version of the class.
      +    *
      +    * @deprecated A {@code serialVersionUID} field in an interface is
      +    * ineffectual. Do not use; no replacement.
           */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 6603384152749567654L;
      
           /**
      --- old/src/java.base/share/classes/java/security/PrivateKey.java   2018-08-09 11:18:34.760000999 -0700
      +++ new/src/java.base/share/classes/java/security/PrivateKey.java   2018-08-09 11:18:34.608000999 -0700
      @@ -63,7 +63,11 @@
           /**
            * The class fingerprint that is set to indicate serialization
            * compatibility with a previous version of the class.
      -     */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
      +      */
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 6034044314589513430L;
       }
      --- old/src/java.base/share/classes/java/security/PublicKey.java    2018-08-09 11:18:35.144000999 -0700
      +++ new/src/java.base/share/classes/java/security/PublicKey.java    2018-08-09 11:18:35.000000999 -0700
      @@ -49,7 +49,11 @@
           /**
            * The class fingerprint that is set to indicate serialization
            * compatibility with a previous version of the class.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 7187392471159151072L;
       }
      --- old/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java 2018-08-09 11:18:35.528000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java 2018-08-09 11:18:35.380000999 -0700
      @@ -47,8 +47,12 @@
           * The class fingerprint that is set to indicate
           * serialization compatibility with a previous
           * version of the class.
      +    *
      +    * @deprecated A {@code serialVersionUID} field in an interface is
      +    * ineffectual. Do not use; no replacement.
           */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 7776497482533790279L;
      
           /**
      --- old/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java  2018-08-09 11:18:35.900000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java  2018-08-09 11:18:35.752000999 -0700
      @@ -47,8 +47,12 @@
           * The class fingerprint that is set to indicate
           * serialization compatibility with a previous
           * version of the class.
      +    *
      +    * @deprecated A {@code serialVersionUID} field in an interface is
      +    * ineffectual. Do not use; no replacement.
           */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 1234526332779022332L;
      
           /**
      --- old/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java  2018-08-09 11:18:36.284000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java  2018-08-09 11:18:36.136000999 -0700
      @@ -42,8 +42,12 @@
          /**
           * The class fingerprint that is set to indicate
           * serialization compatibility.
      +    *
      +    * @deprecated A {@code serialVersionUID} field in an interface is
      +    * ineffectual. Do not use; no replacement.
           */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -7896394956925609184L;
      
           /**
      --- old/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java   2018-08-09 11:18:36.656000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java   2018-08-09 11:18:36.512000999 -0700
      @@ -44,8 +44,12 @@
          /**
           * The class fingerprint that is set to indicate
           * serialization compatibility.
      +    *
      +    * @deprecated A {@code serialVersionUID} field in an interface is
      +    * ineffectual. Do not use; no replacement.
           */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -3314988629879632826L;
      
           /**
      --- old/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java    2018-08-09 11:18:37.024000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java    2018-08-09 11:18:36.884000999 -0700
      @@ -50,8 +50,12 @@
            * The type fingerprint that is set to indicate
            * serialization compatibility with a previous
            * version of the type.
      +    *
      +    * @deprecated A {@code serialVersionUID} field in an interface is
      +    * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 618058533534628008L;
      
           /**
      --- old/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java  2018-08-09 11:18:37.404000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java  2018-08-09 11:18:37.252000999 -0700
      @@ -45,8 +45,12 @@
            * The type fingerprint that is set to indicate
            * serialization compatibility with a previous
            * version of the type.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -5682214253527700368L;
      
           /**
      --- old/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java 2018-08-09 11:18:37.768000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java 2018-08-09 11:18:37.624000999 -0700
      @@ -44,8 +44,12 @@
            * The type fingerprint that is set to indicate
            * serialization compatibility with a previous
            * version of the type.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 5187144804936595022L;
      
           /**
      --- old/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java  2018-08-09 11:18:38.136000999 -0700
      +++ new/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java  2018-08-09 11:18:37.988000999 -0700
      @@ -41,8 +41,12 @@
            * The type fingerprint that is set to indicate
            * serialization compatibility with a previous
            * version of the type.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -8727434096241101194L;
      
           /**
      --- old/src/java.base/share/classes/javax/crypto/SecretKey.java 2018-08-09 11:18:38.508000999 -0700
      +++ new/src/java.base/share/classes/javax/crypto/SecretKey.java 2018-08-09 11:18:38.368000999 -0700
      @@ -63,7 +63,11 @@
           /**
            * The class fingerprint that is set to indicate serialization
            * compatibility since J2SE 1.4.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -4795878709595146952L;
       }
      --- old/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java   2018-08-09 11:18:38.884000999 -0700
      +++ new/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java   2018-08-09 11:18:38.740000999 -0700
      @@ -41,8 +41,12 @@
           /**
            * The class fingerprint that is set to indicate serialization
            * compatibility since J2SE 1.4.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 2211791113380396553L;
      
           /**
      --- old/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java    2018-08-09 11:18:39.248000999 -0700
      +++ new/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java    2018-08-09 11:18:39.108000999 -0700
      @@ -41,8 +41,12 @@
           /**
            * The class fingerprint that is set to indicate serialization
            * compatibility since J2SE 1.4.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -6628103563352519193L;
      
           /**
      --- old/src/java.base/share/classes/javax/crypto/interfaces/PBEKey.java 2018-08-09 11:18:39.624000999 -0700
      +++ new/src/java.base/share/classes/javax/crypto/interfaces/PBEKey.java 2018-08-09 11:18:39.480000999 -0700
      @@ -41,8 +41,12 @@
           /**
            * The class fingerprint that is set to indicate serialization
            * compatibility since J2SE 1.4.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -1430015993304333921L;
      
           /**
      --- old/src/java.base/share/classes/sun/security/internal/interfaces/TlsMasterSecret.java   2018-08-09 11:18:39.996000999 -0700
      +++ new/src/java.base/share/classes/sun/security/internal/interfaces/TlsMasterSecret.java   2018-08-09 11:18:39.856000999 -0700
      @@ -44,7 +44,12 @@
       @Deprecated
       public interface TlsMasterSecret extends SecretKey {
      
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    /***
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
      +     */
      +    @Deprecated
      +    @SuppressWarnings("serial")
           public static final long serialVersionUID = -461748105810469773L;
      
           /**
      --- old/src/java.naming/share/classes/javax/naming/Name.java    2018-08-09 11:18:40.364000999 -0700
      +++ new/src/java.naming/share/classes/javax/naming/Name.java    2018-08-09 11:18:40.224000999 -0700
      @@ -63,8 +63,12 @@
           * The class fingerprint that is set to indicate
           * serialization compatibility with a previous
           * version of the class.
      +    *
      +    * @deprecated A {@code serialVersionUID} field in an interface is
      +    * ineffectual. Do not use; no replacement.
           */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -3617482732056931635L;
      
           /**
      --- old/src/java.naming/share/classes/javax/naming/directory/Attribute.java 2018-08-09 11:18:40.732000999 -0700
      +++ new/src/java.naming/share/classes/javax/naming/directory/Attribute.java 2018-08-09 11:18:40.588000999 -0700
      @@ -335,7 +335,11 @@
      
           /**
            * Use serialVersionUID from JNDI 1.1.1 for interoperability.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
            */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 8707690322213556804L;
       }
      --- old/src/java.rmi/share/classes/java/rmi/server/RemoteRef.java   2018-08-09 11:18:41.100000999 -0700
      +++ new/src/java.rmi/share/classes/java/rmi/server/RemoteRef.java   2018-08-09 11:18:40.952000999 -0700
      @@ -38,8 +38,13 @@
        */
       public interface RemoteRef extends java.io.Externalizable {
      
      -    /** indicate compatibility with JDK 1.1.x version of class. */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    /** indicate compatibility with JDK 1.1.x version of class.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
      +     */
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = 3632638527362204081L;
      
           /**
      --- old/src/java.rmi/share/classes/java/rmi/server/ServerRef.java   2018-08-09 11:18:41.464000999 -0700
      +++ new/src/java.rmi/share/classes/java/rmi/server/ServerRef.java   2018-08-09 11:18:41.324000999 -0700
      @@ -38,8 +38,13 @@
       @Deprecated
       public interface ServerRef extends RemoteRef {
      
      -    /** indicate compatibility with JDK 1.1.x version of class. */
      -    @SuppressWarnings("serial") // serialVersionUID in an interface is ineffectual
      +    /** indicate compatibility with JDK 1.1.x version of class.
      +     *
      +     * @deprecated A {@code serialVersionUID} field in an interface is
      +     * ineffectual. Do not use; no replacement.
      +     */
      +    @Deprecated
      +    @SuppressWarnings("serial")
           static final long serialVersionUID = -4557750989390278438L;
      
           /**

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                darcy Joe Darcy
                Reviewed By:
                Lance Andersen, Roger Riggs, Sean Mullan, Stuart Marks
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: