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

Class-load deadlock when subclass is created by superclass static initializer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P2 P2
    • 1.4.2_11
    • 1.4.2_05
    • hotspot
    • None
    • sparc
    • solaris_9

      The attached Java code deadlocks in the call to
      java.lang.Class.forName0(Native Method).

      If you write code where you construct an instance of a subclass from its
      superclass static initializer and then class-load the superclass and
      subclass from different threads at the same time, the VM is likely to
      deadlock permanently.

      The hang occurs frequently on some systems and less frequently on
      others.

      The issue is similar to that described in bugid: 4295661 which has been
      marked as "Closed, will not be fixed" 'due to a strategic redirection of
      resources to Java 1.4' The deadlock occurs in Java 1.4 as well.




      REPRODUCIBILITY :
      This bug can be reproduced occasionally.

      ---------- BEGIN SOURCE ----------
      public class ClassLoaderHang {
        public static void main(String args[]){
          Thread thread1 =
                  new Thread(
                          new Runnable(){
                            public void run(){
                              ChildA a = new ChildA();
                            }
                          });

          Thread thread2 =
                  new Thread(
                          new Runnable(){
                            public void run(){
                              ChildB b = new ChildB();
                            }
                          });

          thread1.start();
          thread2.start();
        }
      }

      class Parent {
        static{
          Class bClass = ChildB.class;
        }
      }

      class ChildA extends Parent {
        static{
          Class bClass = ChildB.class;
        }
      }

      class ChildB extends Parent {
        static{
          Class parentClass = Parent.class;
        }
      }

      ---------- END SOURCE ----------
      This bug needs to be escalated in-order to get addressed by the sustaining team.

            tmoscovisunw Tal Moscovitz (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: