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

transient final/static fields - allowed or not?

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: laC46010 Date: 10/14/96


      The Java Language Specification says very few words about "transient"
      access modifier. Particularly it doesn't say anything about whether
      are the following access modifier combinations of a class field legal or not:

      transient final
      transient static

      However Java compiler doesn't allow such combinations and reports an error:
      "Transient variables can't be final or static".

      There is an assertion about interface fields [see 9.3 Field (Constant) Declarations]:

      "A constant declaration in an interface must not include any of the modifiers
      synchronized, transient, or volatile, or a compile-time error occurs."

      It prohibits "transient final" fields for interfaces (but not for classes)
      Besides it says nothing about "transient static" combination.

      The specification should explicitly prohibit such combinations
      for both classes and interfaces fields (or compiler should be fixed otherwise)

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abuckley Alex Buckley
                Reporter:
                leosunw Leo Leo (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: