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

[lworld] Javac tolerates synchronizing on a primitive reference type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • repo-valhalla
    • repo-valhalla
    • tools
    • generic
    • generic

      JEP 401 states:

      It is an error if the operand type of a synchronized statement is any subtype of PrimitiveObject, including any primitive reference type.

      // --
      This program compiles fine, but fails at runtime:

      public primitive class X {
          public static void main(String [] args) {
              X.ref x = X.default;
              synchronized (x) {}
          }
      }

      // when run:
      Exception in thread "main" java.lang.IllegalMonitorStateException
      at X.main(X.java:4)


            sadayapalam Srikanth Adayapalam (Inactive)
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: