2323 */
2424
2525/*
26+ * @bug 8320515
2627 * @summary This test checks that ObjectMonitors with dead objects don't
2728 cause asserts, crashes, or failures when various sub-systems
2829 in the JVM find them.
29- * @requires os.family != "windows"
30+ * @requires os.family != "windows" & os.family != "aix"
3031 * @library /testlibrary /test/lib
3132 * @modules jdk.management
3233 */
4243 */
4344
4445/*
45- * @test id=DumpThreadsAfterDetachBeforeJoin
46+ * @test id=DumpThreadsAfterDetach
4647 * @run main/othervm/native MonitorWithDeadObjectTest 2
4748 */
4849
49- /*
50- * @test id=DumpThreadsAfterDetachAfterJoin
51- * @run main/othervm/native MonitorWithDeadObjectTest 3
52- */
53-
5450import java .lang .management .ManagementFactory ;
5551import java .lang .management .ThreadMXBean ;
5652
5753public class MonitorWithDeadObjectTest {
5854 public static native void createMonitorWithDeadObject ();
59- public static native void createMonitorWithDeadObjectNoJoin ();
6055 public static native void createMonitorWithDeadObjectDumpThreadsBeforeDetach ();
6156
62- public static native void joinTestThread ();
63-
6457 static {
6558 System .loadLibrary ("MonitorWithDeadObjectTest" );
6659 }
@@ -72,7 +65,8 @@ private static void dumpThreadsWithLockedMonitors() {
7265
7366 private static void testDetachThread () {
7467 // Create an ObjectMonitor with a dead object from an
75- // attached thread.
68+ // attached thread. This used to provoke an assert
69+ // in DetachCurrentThread.
7670 createMonitorWithDeadObject ();
7771 }
7872
@@ -83,26 +77,13 @@ private static void testDumpThreadsBeforeDetach() {
8377 createMonitorWithDeadObjectDumpThreadsBeforeDetach ();
8478 }
8579
86- private static void testDumpThreadsAfterDetachBeforeJoin () {
87- createMonitorWithDeadObjectNoJoin ();
88-
89- // After createMonitorWithDeadObjectNoJoin has been called, there's an
90- // "owned" monitor with a dead object. The thread dumping code used to
91- // not tolerate such a monitor and would assert. Run a thread dump
92- // and make sure that it doesn't crash/assert.
93- dumpThreadsWithLockedMonitors ();
94-
95- joinTestThread ();
96- }
97-
98- private static void testDumpThreadsAfterDetachAfterJoin () {
99- createMonitorWithDeadObjectNoJoin ();
100- joinTestThread ();
80+ private static void testDumpThreadsAfterDetach () {
81+ createMonitorWithDeadObject ();
10182
102- // After createMonitorWithDeadObjectNoJoin has been called, there's an
103- // "owned" monitor with a dead object. The thread dumping code used to
104- // not tolerate such a monitor and would assert. Run a thread dump
105- // and make sure that it doesn't crash/assert.
83+ // After createMonitorWithDeadObject has been called, there's an "owned"
84+ // monitor with a dead object. The thread dumping code used to not
85+ // tolerate such a monitor and would assert. Run a thread dump and make
86+ // sure that it doesn't crash/assert.
10687 dumpThreadsWithLockedMonitors ();
10788 }
10889
@@ -111,8 +92,7 @@ public static void main(String[] args) throws Exception {
11192 switch (test ) {
11293 case 0 : testDetachThread (); break ;
11394 case 1 : testDumpThreadsBeforeDetach (); break ;
114- case 2 : testDumpThreadsAfterDetachBeforeJoin (); break ;
115- case 3 : testDumpThreadsAfterDetachAfterJoin (); break ;
95+ case 2 : testDumpThreadsAfterDetach (); break ;
11696 default : throw new RuntimeException ("Unknown test" );
11797 };
11898 }
0 commit comments