8038468: java/lang/instrument/ParallelTransformerLoader.sh fails with ClassCircularityError
authorminqi
Wed, 26 Nov 2014 15:33:43 -0800
changeset 28095 194aecee3901
parent 27495 b284622c6569
child 28096 aba953547743
8038468: java/lang/instrument/ParallelTransformerLoader.sh fails with ClassCircularityError Summary: Add check null for loader in transform to avoid when loading a class in callback handler for boot loader, CFLH set early enough to catch classes needed during class loading, i.e. sun.misc.URLClassPath$JarLoader$2 seen in the failure. Reviewed-by: acorn, sspitsyn Contributed-by: yumin.qi@oracle.com
jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java
--- a/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java	Tue Nov 04 18:37:24 2014 -0500
+++ b/jdk/test/java/lang/instrument/ParallelTransformerLoaderAgent.java	Wed Nov 26 15:33:43 2014 -0800
@@ -79,24 +79,15 @@
                         throws IllegalClassFormatException
                 {
                         String tName = Thread.currentThread().getName();
-                        // In 160_03 and older, transform() is called
-                        // with the "system_loader_lock" held and that
-                        // prevents the bootstrap class loaded from
-                        // running in parallel. If we add a slight sleep
-                        // delay here when the transform() call is not
-                        // main or TestThread, then the deadlock in
-                        // 160_03 and older is much more reproducible.
-                        if (!tName.equals("main") && !tName.equals("TestThread")) {
-                            System.out.println("Thread '" + tName +
-                                "' has called transform()");
-                            try {
-                                Thread.sleep(500);
-                            } catch (InterruptedException ie) {
-                            }
-                        }
 
-                        // load additional classes when called from other threads
-                        if (!tName.equals("main"))
+                        // Load additional classes when called from thread 'TestThread'
+                        // When a class is loaded during a callback handling the boot loader, we can
+                        // run into ClassCircularityError if the ClassFileLoadHook is set early enough
+                        // to catch classes needed during class loading, e.g.
+                        //          sun.misc.URLClassPath$JarLoader$2.
+                        // The goal of the test is to stress class loading on the test class loaders.
+
+                        if (tName.equals("TestThread") && loader != null)
                         {
                                 loadClasses(3);
                         }