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

[lworld] Monitorenter fails with VerifyError: Bad type on operand stack

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • repo-valhalla
    • repo-valhalla
    • hotspot

      The following code compiles with javac but fails in the verifier:

      Object o = new MyValue();
      synchronized (o) {
        throw new RuntimeException("synchronization on value type should not succeed");
      }

      Error: Unable to initialize main class Test2
      Caused by: java.lang.VerifyError: Bad type on operand stack
      Exception Details:
        Location:
          Test2.main([Ljava/lang/String;)V @9: monitorenter
        Reason:
          Type 'QMyValue;' (current frame, stack[0]) is not assignable to reference type
        Current Frame:
          bci: @9
          flags: { }
          locals: { '[Ljava/lang/String;', 'QMyValue;', 'QMyValue;' }
          stack: { 'QMyValue;' }
        Bytecode:
          0000000: 102a b800 074c 2b59 4dc2 bb00 0c59 120e
          0000010: b700 10bf 4e2c c32d bf
        Exception Handler Table:
          bci [10, 23] => handler: 20
        Stackmap Table:
          full_frame(@20,{Object[#26],Object[#2],Object[#2]},{Object[#28]})

          Code:
             0: invokestatic #7 // Method MyValue."<init>":()QMyValue;
             3: astore_1
             4: aload_1
             5: dup
             6: astore_2
             7: monitorenter
             8: new #12 // class java/lang/RuntimeException
            11: dup
            12: ldc #14 // String synchronization on value type should not succeed
            14: invokespecial #16 // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
            17: athrow
            18: astore_3
            19: aload_2
            20: monitorexit
            21: aload_3
            22: athrow
          Exception table:
             from to target type
                 8 21 18 any

            hseigel Harold Seigel (Inactive)
            thartmann Tobias Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: