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.
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.