changeset 13244:9f2c7c24a952

7123972: test/java/lang/annotation/loaderLeak/Main.java fails intermittently Reviewed-by: dholmes, smarks Contributed-by: Eric Wang <yiming.wang@oracle.com>
author smarks
date Thu, 05 Jul 2012 15:13:45 -0700
parents 71853d3335a5
children 7ab3ef5b9520
files jdk/test/ProblemList.txt jdk/test/java/lang/annotation/loaderLeak/Main.java
diffstat 2 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/test/ProblemList.txt	Thu Jul 05 15:12:10 2012 -0700
+++ b/jdk/test/ProblemList.txt	Thu Jul 05 15:13:45 2012 -0700
@@ -122,9 +122,6 @@
 
 # jdk_lang
 
-# 7123972
-java/lang/annotation/loaderLeak/Main.java			generic-all
-
 # 6944188
 java/lang/management/ThreadMXBean/ThreadStateTest.java          generic-all
 
--- a/jdk/test/java/lang/annotation/loaderLeak/Main.java	Thu Jul 05 15:12:10 2012 -0700
+++ b/jdk/test/java/lang/annotation/loaderLeak/Main.java	Thu Jul 05 15:13:45 2012 -0700
@@ -57,9 +57,17 @@
         System.gc();
         System.gc();
         loader = null;
-        System.gc();
-        System.gc();
-        if (c.get() != null) throw new AssertionError();
+
+        // Might require multiple calls to System.gc() for weak-references
+        // processing to be complete. If the weak-reference is not cleared as
+        // expected we will hang here until timed out by the test harness.
+        while (true) {
+            System.gc();
+            Thread.sleep(20);
+            if (c.get() == null) {
+                break;
+            }
+        }
     }
 }