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

Excessive exception handlers produced from synchronized sections

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Javac creates two exception blocks on every synchronized section. Second block violates VM spec 4.9.5 (handling exception in proteced code) and differ from sample from 7.14.
      Moreover, if inside syncronized section happens additional monitorexit instruction, offset 21 throws an error and runtime hangs up because second exception block.
      It happens on any java from 1.4.2 upto 1.6.0 and jrockit. Maybe i miss something...

      MonitorExitFail.java:
      public class MonitorExitFail
      {
          public static void main(String[] args)
          {
              Object sync = new Object();
              synchronized (sync) {
                  System.out.println("done!");
              }
          }
      }

      javap -c MonitorExitFail:
      public class MonitorExitFail extends java.lang.Object{
      public MonitorExitFail();
        Code:
         0: aload_0
         1: invokespecial #1; //Method java/lang/Object."<init>":()V
         4: return

      public static void main(java.lang.String[]);
        Code:
         0: new #2; //class java/lang/Object
         3: dup
         4: invokespecial #1; //Method java/lang/Object."<init>":()V
         7: astore_1
         8: aload_1
         9: dup
         10: astore_2
         11: monitorenter
         12: getstatic #3; //Field java/lang/System.out:Ljava/io/PrintStream;
         15: ldc #4; //String done!
         17: invokevirtual #5; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
         20: aload_2
         21: monitorexit
         22: goto 30
         25: astore_3
         26: aload_2
         27: monitorexit
         28: aload_3
         29: athrow
         30: return
        Exception table:
         from to target type
          12 22 25 any
          25 28 25 any

      }

      ###@###.### 2005-06-16 14:33:23 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              wtaosunw Wei Tao (Inactive)
              Reporter:
              azhmursunw Anatoly Zhmur (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: