author | alanb |
Thu, 01 Dec 2016 08:56:41 +0000 | |
changeset 42307 | cefc81dc1d52 |
parent 42036 | 09fd67eeda94 |
child 42647 | d01f2abf2c65 |
permissions | -rw-r--r-- |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
1 |
/* |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
4 |
* |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
8 |
* |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
13 |
* accompanied this code). |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
14 |
* |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
18 |
* |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
21 |
* questions. |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
22 |
*/ |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
23 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
24 |
import java.io.IOException; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
25 |
import java.util.Arrays; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
26 |
import java.util.concurrent.CountDownLatch; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
27 |
import java.util.Set; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
28 |
import java.util.HashSet; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
29 |
import static jdk.test.lib.Asserts.assertTrue; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
30 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
31 |
/** |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
32 |
* @test |
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
33 |
* @summary Tests the modules-related JDWP commands |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
34 |
* @library /test/lib |
42307
cefc81dc1d52
8169069: Module system implementation refresh (11/2016)
alanb
parents:
42036
diff
changeset
|
35 |
* @ignore 8170541 |
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
36 |
* @modules jdk.jdwp.agent |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
37 |
* @modules java.base/jdk.internal.misc |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
38 |
* @compile AllModulesCommandTestDebuggee.java |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
39 |
* @run main/othervm AllModulesCommandTest |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
40 |
*/ |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
41 |
public class AllModulesCommandTest implements DebuggeeLauncher.Listener { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
42 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
43 |
private DebuggeeLauncher launcher; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
44 |
private JdwpChannel channel; |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
45 |
private CountDownLatch jdwpLatch = new CountDownLatch(1); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
46 |
private Set<String> jdwpModuleNames = new HashSet<>(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
47 |
private Set<String> javaModuleNames = new HashSet<>(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
48 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
49 |
public static void main(String[] args) throws Throwable { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
50 |
new AllModulesCommandTest().doTest(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
51 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
52 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
53 |
private void doTest() throws Throwable { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
54 |
launcher = new DebuggeeLauncher(this); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
55 |
launcher.launchDebuggee(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
56 |
// Await till the debuggee sends all the necessary modules info to check against |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
57 |
// then start the JDWP session |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
58 |
jdwpLatch.await(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
59 |
doJdwp(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
60 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
61 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
62 |
@Override |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
63 |
public void onDebuggeeModuleInfo(String modName) { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
64 |
// The debuggee has sent out info about a loaded module |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
65 |
javaModuleNames.add(modName); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
66 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
67 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
68 |
@Override |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
69 |
public void onDebuggeeSendingCompleted() { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
70 |
// The debuggee has completed sending all the info |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
71 |
// We can start the JDWP session |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
72 |
jdwpLatch.countDown(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
73 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
74 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
75 |
@Override |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
76 |
public void onDebuggeeError(String message) { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
77 |
System.err.println("Debuggee error: '" + message + "'"); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
78 |
System.exit(1); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
79 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
80 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
81 |
private void doJdwp() throws Exception { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
82 |
try { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
83 |
// Establish JDWP socket connection |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
84 |
channel = new JdwpChannel(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
85 |
channel.connect(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
86 |
// Send out ALLMODULES JDWP command |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
87 |
// and verify the reply |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
88 |
JdwpAllModulesReply reply = new JdwpAllModulesCmd().send(channel); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
89 |
assertReply(reply); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
90 |
for (int i = 0; i < reply.getModulesCount(); ++i) { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
91 |
long modId = reply.getModuleId(i); |
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
92 |
// For each module reported by JDWP get its name using the JDWP NAME command |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
93 |
// and store the reply |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
94 |
String modName = getModuleName(modId); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
95 |
System.out.println("i=" + i + ", modId=" + modId + ", modName=" + modName); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
96 |
if (modName != null) { // JDWP reports unnamed modules, ignore them |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
97 |
jdwpModuleNames.add(modName); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
98 |
} |
42307
cefc81dc1d52
8169069: Module system implementation refresh (11/2016)
alanb
parents:
42036
diff
changeset
|
99 |
// Assert the CLASSLOADER commands |
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
100 |
assertClassLoader(modId, modName); |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
101 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
102 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
103 |
System.out.println("Module names reported by JDWP: " + Arrays.toString(jdwpModuleNames.toArray())); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
104 |
System.out.println("Module names reported by Java: " + Arrays.toString(javaModuleNames.toArray())); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
105 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
106 |
// Modules reported by the JDWP should be the same as reported by the Java API |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
107 |
if (!jdwpModuleNames.equals(javaModuleNames)) { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
108 |
throw new RuntimeException("Modules info reported by Java API differs from that reported by JDWP."); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
109 |
} else { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
110 |
System.out.println("Test passed!"); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
111 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
112 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
113 |
} finally { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
114 |
launcher.terminateDebuggee(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
115 |
try { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
116 |
new JdwpExitCmd(0).send(channel); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
117 |
channel.disconnect(); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
118 |
} catch (Exception x) { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
119 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
120 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
121 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
122 |
|
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
123 |
private String getModuleName(long modId) throws IOException { |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
124 |
JdwpModNameReply reply = new JdwpModNameCmd(modId).send(channel); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
125 |
assertReply(reply); |
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
126 |
return reply.getModuleName(); |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
127 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
128 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
129 |
private void assertReply(JdwpReply reply) { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
130 |
// Simple assert for any JDWP reply |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
131 |
if (reply.getErrorCode() != 0) { |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
132 |
throw new RuntimeException("Unexpected reply error code " + reply.getErrorCode() + " for reply " + reply); |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
133 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
134 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
135 |
|
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
136 |
private void assertClassLoader(long modId, String modName) throws IOException { |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
137 |
// Verify that the module classloader id is valid |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
138 |
JdwpClassLoaderReply reply = new JdwpClassLoaderCmd(modId).send(channel); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
139 |
assertReply(reply); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
140 |
long moduleClassLoader = reply.getClassLoaderId(); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
141 |
assertTrue(moduleClassLoader >= 0, "bad classloader refId " + moduleClassLoader + " for module '" + modName + "', moduleId=" + modId); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
142 |
|
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
143 |
String clsModName = getModuleName(modId); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
144 |
if ("java.base".equals(clsModName)) { |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
145 |
// For the java.base module, because there will be some loaded classes, we can verify |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
146 |
// that some of the loaded classes do report the java.base module as the module they belong to |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
147 |
assertGetModule(moduleClassLoader, modId); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
148 |
} |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
149 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
150 |
|
42020
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
151 |
private void assertGetModule(long moduleClassLoader, long modId) throws IOException { |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
152 |
// Get all the visible classes for the module classloader |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
153 |
JdwpVisibleClassesReply visibleClasses = new JdwpVisibleClassesCmd(moduleClassLoader).send(channel); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
154 |
assertReply(visibleClasses); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
155 |
|
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
156 |
boolean moduleFound = false; |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
157 |
for (long clsId : visibleClasses.getVisibleClasses()) { |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
158 |
// For each visible class get the module the class belongs to |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
159 |
JdwpModuleReply modReply = new JdwpModuleCmd(clsId).send(channel); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
160 |
assertReply(modReply); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
161 |
long clsModId = modReply.getModuleId(); |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
162 |
|
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
163 |
// At least one of the visible classes should belong to our module |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
164 |
if (modId == clsModId) { |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
165 |
moduleFound = true; |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
166 |
break; |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
167 |
} |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
168 |
} |
8eacd62bf4f7
8166289: RuntimeException: canRead() reports false for reading from the same module: expected true, was false
akulyakh
parents:
41187
diff
changeset
|
169 |
assertTrue(moduleFound, "None of the visible classes for the classloader of the module " + getModuleName(modId) + " reports the module as its own"); |
40891
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
170 |
} |
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
171 |
|
8010999ff6d0
8148103: add more tests for task "Update JDI and JDWP for modules"
akulyakh
parents:
diff
changeset
|
172 |
} |