< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/jvmti/dumpingWithAgent/SimpleAgent.java

Print this page

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -21,10 +21,31 @@
  * questions.
  *
  */
 import java.lang.instrument.Instrumentation;
 
-public class SimpleAgent {
+public class SimpleAgent implements Runnable {
     public static void premain(String agentArg, Instrumentation instrumentation) {
         System.out.println("inside SimpleAgent");
+
+        Thread t = new Thread(new SimpleAgent());
+        t.setDaemon(true);
+        t.start();
+    }
+
+    // Test for JDK-8249276: make sure we can handle objects that are locked during
+    // -Xshare:dump
+    public void run() {
+        try {
+            while (true) {
+                System.out.println("Let's wait .....");
+                synchronized (Object.class) {
+                    Object.class.wait();
+                }
+                System.out.println("Huh?? notified??");
+            }
+        } catch (Throwable t) {
+            System.err.println("Unexpected: " + t);
+            throw new RuntimeException(t);
+        }
     }
 }
< prev index next >