test/java/util/logging/LoggingDeadlock4.java

Print this page

        

@@ -21,15 +21,15 @@
  * questions.
  */
 
 /*
  * @test
- * @bug     6977677
+ * @bug     6977677 8004928
  * @summary Deadlock between LogManager.<clinit> and Logger.getLogger()
  * @author  Daniel D. Daugherty
- * @build LoggingDeadlock4
- * @run main/othervm/timeout=15 -Djava.awt.headless=true LoggingDeadlock4
+ * @compile -XDignore.symbol.file LoggingDeadlock4.java
+ * @run main/othervm/timeout=15 LoggingDeadlock4
  */
 
 import java.util.concurrent.CountDownLatch;
 import java.util.logging.LogManager;
 import java.util.logging.Logger;

@@ -37,24 +37,19 @@
 public class LoggingDeadlock4 {
     private static CountDownLatch barrier      = new CountDownLatch(1);
     private static CountDownLatch lmIsRunning  = new CountDownLatch(1);
     private static CountDownLatch logIsRunning = new CountDownLatch(1);
 
-    public static void main(String[] args) {
-        System.out.println("main: LoggingDeadlock4 is starting.");
-
-        // Loading the java.awt.Container class will create a
-        // sun.util.logging.PlatformLogger$JavaLogger object
+    // Create a sun.util.logging.PlatformLogger$JavaLogger object
         // that has to be redirected when the LogManager class
         // is initialized. This can cause a deadlock between
         // LogManager.<clinit> and Logger.getLogger().
-        try {
-            Class.forName("java.awt.Container");
-        } catch (ClassNotFoundException cnfe) {
-            throw new RuntimeException("Test failed: could not load"
-                + " java.awt.Container." + cnfe);
-        }
+    private static final sun.util.logging.PlatformLogger log = 
+        sun.util.logging.PlatformLogger.getLogger("java.util.logging");
+
+    public static void main(String[] args) {
+        System.out.println("main: LoggingDeadlock4 is starting.");
 
         Thread lmThread = new Thread("LogManagerThread") {
             public void run() {
                 // let main know LogManagerThread is running
                 lmIsRunning.countDown();