Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8071471 Serialization Improvements
  3. JDK-8074022

Serialization should issue a freeze action after reconstituting a graph that contains objects with final fields

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Fixed
    • P3
    • 9
    • None
    • core-libs

    Backports

      Description

        To adhere to final field semantics Serialization should issue a "freeze action" after reconstituting objects that have values set on their final fields, see JLS 17.5 [1].

        A number of years ago there was a proposal to use Unsafe.put*Volatile methods to set final fields during default deserialisation, JDK-6647361 [2][3], but it never made it due to concerns about the potential negative impact of the additional fences. Now we have a, private, fences API in the platform, I think it is time to revisit this.

        Note:
            Section 17.5.3 in the JLS [3], “Freezes of a final field occur both
            at the end of the constructor in which the final field is set, and
            immediately after each modification of a final field via reflection
            or other special mechanism.” I believe this is a consequence of
            the way in which setting of final fields is supported in the public
            API, Field.setAccessible(), ( as defined by JSR 133 ) and should
            not restrict an implementation from using a more performant
            means, as is suggested here. The statement in the JLS should
            be revisited.

        [1] http://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html#jls-17.5
        [2] https://bugs.openjdk.java.net/browse/JDK-6647361
        [3] http://mail.openjdk.java.net/pipermail/core-libs-dev/2010-November/005292.html
             http://mail.openjdk.java.net/pipermail/core-libs-dev/2010-December/005456.html
        [4] http://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html#jls-17.5.3

        Attachments

          Issue Links

            Activity

              People

                chegar Chris Hegarty
                chegar Chris Hegarty
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: