8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE
authordsamersoff
Tue, 30 Aug 2016 11:06:25 +0300
changeset 40889 adf083cbc37f
parent 40887 8d35e19f5548
child 40890 6ac37e8b717a
8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE Summary: Addition of –XX:+UnlockDiagnosticVMOptions for the test invocation for jcmd and modularization related cleanup Reviewed-by: dholmes, mchung Contributed-by: jini.george@oracle.com
hotspot/test/serviceability/sa/TestInstanceKlassSize.java
hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java
--- 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();
     }
--- a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java	Mon Aug 29 20:13:45 2016 -0400
+++ b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java	Tue Aug 30 11:06:25 2016 +0300
@@ -38,15 +38,20 @@
  * @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
  *          TestInstanceKlassSizeForInterface.java
- * @run main/othervm TestInstanceKlassSizeForInterface
+ * @run main/othervm
+ *          -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
+ *          TestInstanceKlassSizeForInterface
  */
 
 interface Language {
@@ -80,6 +85,8 @@
         for (String instanceKlassName : instanceKlassNames) {
             InstanceKlass iKlass = SystemDictionaryHelper.findInstanceKlass(
                                        instanceKlassName);
+            Asserts.assertNotNull(iKlass,
+                String.format("Unable to find instance klass for %s", instanceKlassName));
             System.out.println("SA: The size of " + instanceKlassName +
                                " is " + iKlass.getSize());
         }
@@ -106,11 +113,11 @@
 
         // Grab the pid from the current java process and pass it
         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",
             "TestInstanceKlassSizeForInterface",
             Long.toString(ProcessTools.getProcessId())
         };
@@ -138,6 +145,8 @@
             String jcmdInstanceKlassSize = getJcmdInstanceKlassSize(
                                                       jcmdOutput,
                                                       instanceKlassName);
+            Asserts.assertNotNull(jcmdInstanceKlassSize,
+                "Could not get the instance klass size from the jcmd output");
             for (String s : SAOutput.asLines()) {
                 if (s.contains(instanceKlassName)) {
                    Asserts.assertTrue(
@@ -162,7 +171,7 @@
             return;
         }
 
-        if ( args == null || args.length == 0 ) {
+        if (args == null || args.length == 0) {
             ParselTongue lang = new ParselTongue();
 
             Language ventro = new Language() {