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

-Xlint:serial does not flag abstract classes with concrete methods/members

XMLWordPrintable

    • b100
    • x86
    • linux
    • Verified

      FULL PRODUCT VERSION :
      javac 1.5.0_01
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux kgregory-lin 2.6.8.1-24mdkenterprise #1 SMP Fri Jan 14 00:31:44 MST 2005 i686 Intel(R) Pentium(R) 4 CPU 3.60GHz unknown GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The -Xlint:serial option will not flag an abstract class that does not define serialVersionUID, but the serialization subsystem does calculate a default UID for the class. This will result in runtime errors when the class changes in a way that Java considers incompatible.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile example with

      javac -Xlint:serial SerializableAbstract.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      SerializableAbstract.java:1: warning: [serial] serializable class SerializableAbstract has no definition of serialVersionUID

      ACTUAL -
      No warnings; compilation completes successfully.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public abstract class SerializableAbstract
      implements java.io.Serializable
      {
          private int x;

          public int incrementX() {
              return ++x;
          }
          
          public abstract int decrementX();
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      none - must visually inspect abstract classes, create serialVersionUID tag where appropriate

            vromero Vicente Arturo Romero Zaldivar
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: