changeset 12018:ad12e539a414

8166312: Backout 8165017 Summary: backout of the change for JDK-8165017 because tests failed on windows Reviewed-by: ctornqvi, dholmes, gtriantafill
author hseigel
date Mon, 19 Sep 2016 19:25:09 -0400
parents 9f7f714bf3e8
children 03adb9739db8
files test/serviceability/jdwp/AllModulesCommandTest.java test/serviceability/jdwp/JdwpCmd.java test/serviceability/jdwp/JdwpModuleCmd.java test/serviceability/jdwp/JdwpModuleReply.java test/serviceability/jdwp/JdwpVisibleClassesCmd.java test/serviceability/jdwp/JdwpVisibleClassesReply.java
diffstat 6 files changed, 13 insertions(+), 199 deletions(-) [+]
line wrap: on
line diff
--- a/test/serviceability/jdwp/AllModulesCommandTest.java	Mon Sep 19 22:55:26 2016 +0200
+++ b/test/serviceability/jdwp/AllModulesCommandTest.java	Mon Sep 19 19:25:09 2016 -0400
@@ -30,7 +30,7 @@
 
 /**
  * @test
- * @summary Tests the modules-related JDWP commands
+ * @summary Tests AllModules JDWP command
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @compile AllModulesCommandTestDebuggee.java
@@ -87,12 +87,8 @@
             assertReply(reply);
             for (int i = 0; i < reply.getModulesCount(); ++i) {
                 long modId = reply.getModuleId(i);
-                // For each module reported by JDWP get its name using the JDWP NAME command
-                // and store the reply
-                String modName = getModuleName(modId);
-                if (modName != null) { // JDWP reports unnamed modules, ignore them
-                    jdwpModuleNames.add(modName);
-                }
+                // For each module reported by JDWP get its name using the JDWP  NAME command
+                getModuleName(modId);
                 // Assert the JDWP CANREAD and CLASSLOADER commands
                 assertCanRead(modId);
                 assertClassLoader(modId);
@@ -118,10 +114,14 @@
         }
     }
 
-    private String getModuleName(long modId) throws IOException {
+    private void getModuleName(long modId) throws IOException {
+        // Send out the JDWP NAME command and store the reply
         JdwpModNameReply reply = new JdwpModNameCmd(modId).send(channel);
         assertReply(reply);
-        return reply.getModuleName();
+        String modName = reply.getModuleName();
+        if (modName != null) { // JDWP reports unnamed modules, ignore them
+            jdwpModuleNames.add(modName);
+        }
     }
 
     private void assertReply(JdwpReply reply) {
@@ -139,39 +139,11 @@
     }
 
     private void assertClassLoader(long modId) throws IOException {
-        // Verify that the module classloader id is valid
+        // Simple assert for the CLASSLOADER command
         JdwpClassLoaderReply reply = new JdwpClassLoaderCmd(modId).send(channel);
         assertReply(reply);
-        long moduleClassLoader = reply.getClassLoaderId();
-        assertTrue(moduleClassLoader >= 0, "bad classloader refId " + moduleClassLoader + " for module id " + modId);
-
-        String clsModName = getModuleName(modId);
-        if ("java.base".equals(clsModName)) {
-            // For the java.base module, because there will be some loaded classes, we can verify
-            // that some of the loaded classes do report the java.base module as the module they belong to
-            assertGetModule(moduleClassLoader, modId);
-        }
-    }
-
-    private void assertGetModule(long moduleClassLoader, long modId) throws IOException {
-        // Get all the visible classes for the module classloader
-        JdwpVisibleClassesReply visibleClasses = new JdwpVisibleClassesCmd(moduleClassLoader).send(channel);
-        assertReply(visibleClasses);
-
-        boolean moduleFound = false;
-        for (long clsId : visibleClasses.getVisibleClasses()) {
-            // For each visible class get the module the class belongs to
-            JdwpModuleReply modReply = new JdwpModuleCmd(clsId).send(channel);
-            assertReply(modReply);
-            long clsModId = modReply.getModuleId();
-
-            // At least one of the visible classes should belong to our module
-            if (modId == clsModId) {
-                moduleFound = true;
-                break;
-            }
-        }
-        assertTrue(moduleFound, "None of the visible classes for the classloader of the module " + getModuleName(modId) + " reports the module as its own");
+        long clId = reply.getClassLoaderId();
+        assertTrue(clId >= 0, "bad classloader refId " + clId + " for module id " + modId);
     }
 
 }
--- a/test/serviceability/jdwp/JdwpCmd.java	Mon Sep 19 22:55:26 2016 +0200
+++ b/test/serviceability/jdwp/JdwpCmd.java	Mon Sep 19 19:25:09 2016 -0400
@@ -70,6 +70,7 @@
     }
 
     public final T send(JdwpChannel channel) throws IOException {
+        System.err.println("Sending command: " + this);
         channel.write(data.array(), HEADER_LEN + getDataLength());
         if (reply != null) {
             reply.initFromStream(channel.getInputStream());
--- a/test/serviceability/jdwp/JdwpModuleCmd.java	Mon Sep 19 22:55:26 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2016, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * The JDWP MODULE command
- */
-public class JdwpModuleCmd extends JdwpCmd<JdwpModuleReply> {
-
-    public JdwpModuleCmd(long refId) {
-        super(19, 2, JdwpModuleReply.class, refLen());
-        putRefId(refId);
-    }
-
-}
--- a/test/serviceability/jdwp/JdwpModuleReply.java	Mon Sep 19 22:55:26 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2016, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-/**
- * The reply to the JDWP MODULE command
- */
-public class JdwpModuleReply extends JdwpReply {
-
-    private long moduleId;
-
-    protected void parseData(DataInputStream ds) throws IOException {
-        moduleId = readRefId(ds);
-    }
-
-    public long getModuleId() {
-        return moduleId;
-    }
-
-}
--- a/test/serviceability/jdwp/JdwpVisibleClassesCmd.java	Mon Sep 19 22:55:26 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2016, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * The JDWP VISIBLE CLASSES command
- */
-public class JdwpVisibleClassesCmd extends JdwpCmd<JdwpVisibleClassesReply> {
-
-    public JdwpVisibleClassesCmd(long classLoaderId) {
-        super(1, 14, JdwpVisibleClassesReply.class, refLen());
-        putRefId(classLoaderId);
-    }
-
-}
--- a/test/serviceability/jdwp/JdwpVisibleClassesReply.java	Mon Sep 19 22:55:26 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2016, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.Arrays;
-
-/**
- * The reply to the JDWP VISIBLE CLASSES command
- */
-public class JdwpVisibleClassesReply extends JdwpReply {
-
-    private long[] visibleClasses;
-
-    protected void parseData(DataInputStream ds) throws IOException {
-        int numOfClasses = ds.readInt();
-        visibleClasses = new long[numOfClasses];
-        for (int i = 0; i < numOfClasses; ++i) {
-            byte type = ds.readByte();
-            long refId = readRefId(ds);
-            visibleClasses[i] = refId;
-        }
-    }
-
-    public long[] getVisibleClasses() {
-        return Arrays.copyOf(visibleClasses, visibleClasses.length);
-    }
-
-}