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

compiler allows final field declared volatile

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1fcs
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description



      Name: laC46010 Date: 10/14/96


      The section "8.3.1.4 volatile Fields" of The Java Language Specification requires:

      "A compile-time error occurs if a final variable is also declared volatile. "

      However compilers (both 1.0.2 and 1.1) don't report anything:

      > javac -d . clss09001.java
      > ja11 -verify javasoft.sqe.tests.lang.clss090.clss09001.clss09001
      Passed.
      >
      --------------------------clss09001.java------------------------------
      // Ident: %Z%%M% %I% %E%
      // Copyright %G% Sun Microsystems, Inc. All Rights Reserved
      package javasoft.sqe.tests.lang.clss090.clss09001;
      import java.io.PrintStream;

      class clss09001 {
        volatile final int var = 9001;
        public static void main(String argv[])
        {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
        public static int run(String argv[],PrintStream out) {
         clss09001 x = new clss09001();
         if (x.var == 9001) {
         out.println("Passed.");
         return(0/*STATUS_PASS*/);
         } else {
         out.println("Failed.");
         return(2/*STATUS_FAILED*/);
         }
        }
      }
      -----------------------------------------------------------------

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

        Attachments

          Activity

            People

            Assignee:
            dstoutamsunw David Stoutamire (Inactive)
            Reporter:
            leosunw Leo Leo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: