79 throws IllegalClassFormatException 80 { 81 String tName = Thread.currentThread().getName(); 82 // In 160_03 and older, transform() is called 83 // with the "system_loader_lock" held and that 84 // prevents the bootstrap class loaded from 85 // running in parallel. If we add a slight sleep 86 // delay here when the transform() call is not 87 // main or TestThread, then the deadlock in 88 // 160_03 and older is much more reproducible. 89 if (!tName.equals("main") && !tName.equals("TestThread")) { 90 System.out.println("Thread '" + tName + 91 "' has called transform()"); 92 try { 93 Thread.sleep(500); 94 } catch (InterruptedException ie) { 95 } 96 } 97 98 // load additional classes when called from other threads 99 if (!tName.equals("main")) 100 { 101 loadClasses(3); 102 } 103 return null; 104 } 105 106 public static void 107 loadClasses( int index) 108 { 109 ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader(); 110 try 111 { 112 Class.forName("TestClass" + index, true, loader); 113 } 114 catch (Exception e) 115 { 116 e.printStackTrace(); 117 } 118 } 119 } 120 } | 79 throws IllegalClassFormatException 80 { 81 String tName = Thread.currentThread().getName(); 82 // In 160_03 and older, transform() is called 83 // with the "system_loader_lock" held and that 84 // prevents the bootstrap class loaded from 85 // running in parallel. If we add a slight sleep 86 // delay here when the transform() call is not 87 // main or TestThread, then the deadlock in 88 // 160_03 and older is much more reproducible. 89 if (!tName.equals("main") && !tName.equals("TestThread")) { 90 System.out.println("Thread '" + tName + 91 "' has called transform()"); 92 try { 93 Thread.sleep(500); 94 } catch (InterruptedException ie) { 95 } 96 } 97 98 // load additional classes when called from other threads 99 // with system class loader. If we use the same class loader as 100 // in other thread, it will throw CircularityError since 101 // this loading is in middle of loading TestClass2 and cause 102 // CircularityError for JarLoader$2 which is put in placeholder 103 // but not loaded yet. We see it twice on stack, Detail see 104 // bug 8038468 105 if (!tName.equals("main")) 106 { 107 loadClasses(3); 108 } 109 return null; 110 } 111 112 public static void 113 loadClasses( int index) 114 { 115 // ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader(); 116 try 117 { 118 //Class.forName("TestClass" + index, true, loader); 119 Class.forName("TestClass" + index, true, ClassLoader.getSystemClassLoader()); 120 } 121 catch (Exception e) 122 { 123 e.printStackTrace(); 124 } 125 } 126 } 127 } |