hotspot/test/serviceability/sa/TestInstanceKlassSize.java
changeset 40889 adf083cbc37f
parent 40631 ed82623d7831
child 42075 e5b263ac8c2e
--- a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java	Mon Aug 29 20:13:45 2016 -0400
+++ b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java	Tue Aug 30 11:06:25 2016 +0300
@@ -23,6 +23,7 @@
 
 import sun.jvm.hotspot.HotSpotAgent;
 import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
+import sun.jvm.hotspot.oops.InstanceKlass;
 import sun.jvm.hotspot.debugger.*;
 
 import java.util.ArrayList;
@@ -44,15 +45,19 @@
  * @test
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
- * @modules jdk.hotspot.agent
- * @modules jdk.hotspot.agent/sun.jvm.hotspot
- * @modules jdk.hotspot.agent/sun.jvm.hotspot.utilities
- * @modules jdk.hotspot.agent/sun.jvm.hotspot.oops
- * @compile -XDignore.symbol.file=true -Xmodule:jdk.hotspot.agent
- *          -XaddExports:java.base/jdk.internal.misc=jdk.hotspot.agent
- *          -XaddExports:java.management/java.lang.management=jdk.hotspot.agent
+ * @compile -XDignore.symbol.file=true
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED
  *          TestInstanceKlassSize.java
- * @run main/othervm  TestInstanceKlassSize
+ * @run main/othervm
+ *          --add-modules=jdk.hotspot.agent
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED
+ *          --add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED
+ *          TestInstanceKlassSize
  */
 
 public class TestInstanceKlassSize {
@@ -112,11 +117,11 @@
                                               " java.lang.Byte",
                                           };
             String[] toolArgs = {
-                "-XX:+UnlockDiagnosticVMOptions",
                 "--add-modules=jdk.hotspot.agent",
                 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
                 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
                 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+                "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED",
                 "TestInstanceKlassSize",
                 Long.toString(app.getPid())
             };
@@ -136,6 +141,8 @@
                 String jcmdInstanceKlassSize = getJcmdInstanceKlassSize(
                                                       jcmdOutput,
                                                       instanceKlassName);
+                Asserts.assertNotNull(jcmdInstanceKlassSize,
+                    "Could not get the instance klass size from the jcmd output");
                 for (String s : output.asLines()) {
                     if (s.contains(instanceKlassName)) {
                        Asserts.assertTrue(
@@ -165,10 +172,12 @@
         }
 
         for (String SAInstanceKlassName : SAInstanceKlassNames) {
-            Long size = SystemDictionaryHelper.findInstanceKlass(
-                            SAInstanceKlassName).getSize();
+            InstanceKlass ik = SystemDictionaryHelper.findInstanceKlass(
+                               SAInstanceKlassName);
+            Asserts.assertNotNull(ik,
+                String.format("Unable to find instance klass for %s", ik));
             System.out.println("SA: The size of " + SAInstanceKlassName +
-                               " is " + size);
+                               " is " + ik.getSize());
         }
         agent.detach();
     }