[lworld] Javac tolerates synchronizing on a primitive reference type

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • repo-valhalla
    • Affects Version/s: repo-valhalla
    • Component/s: 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)


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

              Created:
              Updated:
              Resolved: