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

static initializer versus serialization: Incompatibility between 1.4.0 and 1.4.1

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • None
    • 1.4.1
    • tools
    • x86
    • windows_xp

    Description



      Name: rmT116609 Date: 02/26/2003


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      also:

      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows XP [Version 5.1.2600]
      with Service Pack 1 installed

      A DESCRIPTION OF THE PROBLEM :
      There did not appear to be a bug report for this, but there was a somewhat related bug at ...
      http://developer.java.sun.com/developer/bugParade/bugs/42917
      57.html

      There is a subtle change that is going to require a recompilation of all code and restart of the java servers and clients using RMI to get from 1.4.0 to 1.4.1.

      The issue concerns how Java handles the initialization of final static
      variables, i.e.,
      public class Example {
              final static int one = 1;
      }
      Since such variables are final(constant), static(a class variable), and
      not a compilicated object with a constructor, it is possible for a compiler to initialize all references to them at compile time or less optimaly to actualy define and run a routine, static(), to init them when the class is loaded. Java 1.4.0 and 1.4.1 differ on with choice they make. Java 1.4.0 defines the static() function when - g is set on the compile, but not when -g is not set independent of the optimization flag(-O). Java 1.4.1 does not define the static() function for both the -g and no -g case again independent of optimization. This means that the *.class files generated with -g on differ from 1.4.0 to 1.4.1 even for an identical *.java. This difference appears to be the cause of the serializations between say server on 1.4.0 w/ -g to mismatch a client on 1.4.1 w/ -g.

      I did not see any indication of this binary incompatibility in the release notes. I am not requesting that this be fixed but it would helpful if you could confirm this diagnosis and report it in the release notes. For a minor release I would not have expected to have to recompile and restart all our RMI systems.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile above code with javac -g using 1.4.0 and 1.4.1
      2. Run javap -c on both
      3. Observe that 1.4.0 defines static() but 1.4.1 does not
      4. Attempts to serialize an instance of this class fail
      between a server compiled with 1.4.0 -g and a client with 1.4.1 -g.
      5. My speculation is that the serialization issue reported in 4 is caused by the difference observed in 3.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Example {
              final static int one = 1;
      }

      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      Recompile and restart all servers and clients when going from 1.4.0 to 1.4.1.
      (Review ID: 166178)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              gafter Neal Gafter
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: