equal
deleted
inserted
replaced
30 |
30 |
31 /** |
31 /** |
32 * @test |
32 * @test |
33 * @summary Tests the modules-related JDWP commands |
33 * @summary Tests the modules-related JDWP commands |
34 * @library /test/lib |
34 * @library /test/lib |
35 * @ignore 8168478 |
35 * @ignore 8170541 |
36 * @modules jdk.jdwp.agent |
36 * @modules jdk.jdwp.agent |
37 * @modules java.base/jdk.internal.misc |
37 * @modules java.base/jdk.internal.misc |
38 * @compile AllModulesCommandTestDebuggee.java |
38 * @compile AllModulesCommandTestDebuggee.java |
39 * @run main/othervm AllModulesCommandTest |
39 * @run main/othervm AllModulesCommandTest |
40 */ |
40 */ |
94 String modName = getModuleName(modId); |
94 String modName = getModuleName(modId); |
95 System.out.println("i=" + i + ", modId=" + modId + ", modName=" + modName); |
95 System.out.println("i=" + i + ", modId=" + modId + ", modName=" + modName); |
96 if (modName != null) { // JDWP reports unnamed modules, ignore them |
96 if (modName != null) { // JDWP reports unnamed modules, ignore them |
97 jdwpModuleNames.add(modName); |
97 jdwpModuleNames.add(modName); |
98 } |
98 } |
99 // Assert the JDWP CANREAD and CLASSLOADER commands |
99 // Assert the CLASSLOADER commands |
100 assertCanRead(modId, modName); |
|
101 assertClassLoader(modId, modName); |
100 assertClassLoader(modId, modName); |
102 } |
101 } |
103 |
102 |
104 System.out.println("Module names reported by JDWP: " + Arrays.toString(jdwpModuleNames.toArray())); |
103 System.out.println("Module names reported by JDWP: " + Arrays.toString(jdwpModuleNames.toArray())); |
105 System.out.println("Module names reported by Java: " + Arrays.toString(javaModuleNames.toArray())); |
104 System.out.println("Module names reported by Java: " + Arrays.toString(javaModuleNames.toArray())); |
130 private void assertReply(JdwpReply reply) { |
129 private void assertReply(JdwpReply reply) { |
131 // Simple assert for any JDWP reply |
130 // Simple assert for any JDWP reply |
132 if (reply.getErrorCode() != 0) { |
131 if (reply.getErrorCode() != 0) { |
133 throw new RuntimeException("Unexpected reply error code " + reply.getErrorCode() + " for reply " + reply); |
132 throw new RuntimeException("Unexpected reply error code " + reply.getErrorCode() + " for reply " + reply); |
134 } |
133 } |
135 } |
|
136 |
|
137 private void assertCanRead(long modId, String modName) throws IOException { |
|
138 // Simple assert for the CANREAD command |
|
139 JdwpCanReadReply reply = new JdwpCanReadCmd(modId, modId).send(channel); |
|
140 assertReply(reply); |
|
141 assertTrue(reply.canRead(), "canRead() reports false for reading from the same module '" + modName + "', moduleId=" + modId); |
|
142 } |
134 } |
143 |
135 |
144 private void assertClassLoader(long modId, String modName) throws IOException { |
136 private void assertClassLoader(long modId, String modName) throws IOException { |
145 // Verify that the module classloader id is valid |
137 // Verify that the module classloader id is valid |
146 JdwpClassLoaderReply reply = new JdwpClassLoaderCmd(modId).send(channel); |
138 JdwpClassLoaderReply reply = new JdwpClassLoaderCmd(modId).send(channel); |