Hi, I am wondering if someone may be able to point me in the right direction here... after reviewing the J2SE spec, and the Servlet 2.4 Spec, its not too clear whether circular dependecies such as the one I am investigating below are legal or supported by Tomcat. Sun J2SE 5.0 classloader does not seem to support such initialization although the Tomcat classloader (v5.5) seems to an operation such as my example below.
An exert of the Java specification states: 12.4.2, #3 If initialization is in progress for the class or interface by the current thread, then this must be a recursive request for initialization. Release the lock on the Class object and complete normally. Servlet 2.4 spec says that Classloaders need to follow the J2SE specification. So as I am investigating the Tomcat 5.5 classloader I am wondering if either one of these situations are legal for Tomcat 5.5 or whether I should be observing a ClassCircularityError... debugging my App shows the following behavior: Examples : Class A { static { System.out.println(B.somefield); // debugger shows that A is checked and the static block is invoked. B is loaded which initializes B.somefield through the constructor of A. } } Class B { public static final A somefield; } and/or circular dependecy from Parent static initializers Class Parent { static { System.out.println(B.somefield); // debugger shows A is checked, Parent is loaded which loads B which loads somefield through the constructor of class "A" } } Class A extends Parent { } Class B { public static final A somefield; } Thanks in advance. Best Regards, Mich