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

async exceptions versus return in try in synchronized

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 1.4.1
    • 1.4.0
    • tools
    • hopper
    • generic
    • solaris_8
    • Verified

    Description

      The following is narrowed down from com.sun.naming.internal.FactoryEnumeration,
      method next()

      In the following code, a RuntimeEcception occurring at
      instruction 8 or 9 will cause a redundant monitorexit.
      The join point with mismatching monitors causes a C1 assertion failure.

      frog:~/gjc-work/j2se-tl $ cat -n T.java
           1 class T {
           2 static int f(Object o, int x) {
           3 synchronized (o) {
           4 try {
           5 return x;
           6 } catch (RuntimeException e) {
           7 throw e;
           8 }
           9 }
          10 }
          11 }
      frog:~/gjc-work/j2se-tl $ newjavac T.java
      frog:~/gjc-work/j2se-tl $ javap -c -l T
      Compiled from T.java
      class T extends java.lang.Object {
          T();
          static int f(java.lang.Object, int);
      }

      Method T()
         0 aload_0
         1 invokespecial #1 <Method java.lang.Object()>
         4 return

      Line numbers for method T()
         line 1: 0

      Method int f(java.lang.Object, int)
         0 aload_0
         1 astore_2
         2 aload_2
         3 monitorenter
         4 iload_1
         5 istore_3
         6 aload_2
         7 monitorexit
         8 iload_3
         9 ireturn
        10 astore_3
        11 aload_3
        12 athrow
        13 astore 4
        15 aload_2
        16 monitorexit
        17 aload 4
        19 athrow
      Exception table:
         from to target type
           4 10 10 <Class java.lang.RuntimeException>
           4 8 13 any
          10 17 13 any

      Line numbers for method int f(java.lang.Object, int)
         line 3: 0
         line 5: 4
         line 7: 10
         line 9: 13
      frog:~/gjc-work/j2se-tl $

      Attachments

        Activity

          People

            gafter Neal Gafter
            gafter Neal Gafter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: