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

Stack dump should show more clearly when a thread is blocked on a class initialization monitor

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 13
    • 11, 12
    • hotspot
    • b04

      If a thread tries to access a class for which static initialization is still in progress, it will block on the VM internal "class initialization monitor". When this happens the stack trace for the thread is quite cryptic e.g.

      "pool-1-thread-1" #14 prio=5 os_prio=0 tid=0x0000000024925800 nid=0x449c in Object.wait() [0x00000000251be000]
         java.lang.Thread.State: RUNNABLE
              at Main$$Lambda$1/26117480.call(Unknown Source)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
              at java.lang.Thread.run(Thread.java:748)

      We can see the thread is blocked in Object.wait() but the first Java frame does not contain code that has an explicit Object.wait in it. So this is quite puzzling to the user.

      We should augment the output somehow to show that it is in fact blocked on a class initialization monitor.

            dholmes David Holmes
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: