43 * For maxInstances in [1, 0, Interger.MAX_VALUE]
44 * do
45 * Debugger obtains referenceTypeID for 'nsk.share.jdwp.ReferenceType.instances.instances001.TestClass'.
46 * Then, debugger creates command packet for Instances command with the
47 * found referenceTypeID and maxInstances as an arguments, writes packet to the transport
48 * channel, and waits for a reply packet.
49 * When reply packet is received, debugger parses the packet structure
50 * and extracts number of instances and instance's ids.
51 * Debugger checks that received number of instances is correct:
52 * - if maxInstances=1 only 1 instance should be returned
53 * - if maxInstances=0 or maxInstances=Integer.MAX_VALUE all instances should be returned
54 * done
55 * Also, test performs checks for cases when incorrect data is sent in command.
56 * Following cases are tested:
57 * - create command with maxInstances < 0, expect ILLEGAL_ARGUMENT error
58 * - create command with typeID = -1, expect INVALID_OBJECT error
59 * - create command with threadID instead of referenceTypeID, expect INVALID_CLASS error
60 * Finally, debugger sends debuggee signal to quit, waits for it exits
61 * and exits too with the proper exit code.
62 *
63 * @library /vmTestbase /test/hotspot/jtreg/vmTestbase
64 * /test/lib
65 * @run driver jdk.test.lib.FileInstaller . .
66 * @build nsk.jdwp.ReferenceType.Instances.instances001.instances001
67 * @run main/othervm/native PropertyResolvingWrapper
68 * nsk.jdwp.ReferenceType.Instances.instances001.instances001
69 * -arch=${os.family}-${os.simpleArch}
70 * -verbose
71 * -waittime=5
72 * -debugee.vmkind=java
73 * -transport.address=dynamic
74 * -debugee.vmkeys="-Xmx128M ${test.vm.opts} ${test.java.opts}"
75 */
76
77 package nsk.jdwp.ReferenceType.Instances.instances001;
78
79 import java.io.*;
80 import nsk.share.Consts;
81 import nsk.share.jdwp.*;
82 import nsk.share.jpda.AbstractDebuggeeTest;
139 setSuccess(false);
140 log.complain("Caught exception while testing JDWP command: " + e);
141 e.printStackTrace(log.getOutStream());
142 }
143 }
144
145 public void doTest() {
146 // force GC in debuggee VM to avoid collection of weak references during test execution
147 forceGC();
148 pipe.println(instances001a.COMMAND_CREATE_TEST_INSTANCES);
149
150 if (!isDebuggeeReady())
151 return;
152
153 int expectedInstances = instances001a.expectedCount;
154
155 String testClassName = nsk.jdwp.ReferenceType.Instances.instances001.TestClass.class.getName();
156
157 long typeID = debuggee.getReferenceTypeID(createTypeSignature(testClassName));
158
159
160 // create command with maxInstances=1, only 1 instance should be returned
161 testClass(typeID, 1, 1, false, 0);
162 // create command with maxInstances=0, all instances should be returned
163 testClass(typeID, 0, expectedInstances, false, 0);
164 // create command with maxInstances=Integer.MAX_VALUE, all instances should be returned
165 testClass(typeID, Integer.MAX_VALUE, expectedInstances, false, 0);
166
167 // create command with maxInstances < 0, expect ILLEGAL_ARGUMENT error
168 testClass(typeID, -1, expectedInstances, true, JDWP.Error.ILLEGAL_ARGUMENT);
169
170 // create command with typeID = 1, expect INVALID_OBJECT error
171 testClass(-1, Integer.MAX_VALUE, expectedInstances, true, JDWP.Error.INVALID_OBJECT);
172
173 // create command with threadID instead of referenceTypeID, expect INVALID_CLASS error
174 testClass(debuggee.getThreadID("main"), Integer.MAX_VALUE, expectedInstances, true, JDWP.Error.INVALID_CLASS);
175
176 // if GC occurs during test the results should be ignored
177 resetStatusIfGC();
178 }
|
43 * For maxInstances in [1, 0, Interger.MAX_VALUE]
44 * do
45 * Debugger obtains referenceTypeID for 'nsk.share.jdwp.ReferenceType.instances.instances001.TestClass'.
46 * Then, debugger creates command packet for Instances command with the
47 * found referenceTypeID and maxInstances as an arguments, writes packet to the transport
48 * channel, and waits for a reply packet.
49 * When reply packet is received, debugger parses the packet structure
50 * and extracts number of instances and instance's ids.
51 * Debugger checks that received number of instances is correct:
52 * - if maxInstances=1 only 1 instance should be returned
53 * - if maxInstances=0 or maxInstances=Integer.MAX_VALUE all instances should be returned
54 * done
55 * Also, test performs checks for cases when incorrect data is sent in command.
56 * Following cases are tested:
57 * - create command with maxInstances < 0, expect ILLEGAL_ARGUMENT error
58 * - create command with typeID = -1, expect INVALID_OBJECT error
59 * - create command with threadID instead of referenceTypeID, expect INVALID_CLASS error
60 * Finally, debugger sends debuggee signal to quit, waits for it exits
61 * and exits too with the proper exit code.
62 *
63 * @requires vm.gc != "Z"
64 * @library /vmTestbase /test/hotspot/jtreg/vmTestbase
65 * /test/lib
66 * @run driver jdk.test.lib.FileInstaller . .
67 * @build nsk.jdwp.ReferenceType.Instances.instances001.instances001
68 * @run main/othervm/native PropertyResolvingWrapper
69 * nsk.jdwp.ReferenceType.Instances.instances001.instances001
70 * -arch=${os.family}-${os.simpleArch}
71 * -verbose
72 * -waittime=5
73 * -debugee.vmkind=java
74 * -transport.address=dynamic
75 * -debugee.vmkeys="-Xmx128M ${test.vm.opts} ${test.java.opts}"
76 */
77
78 package nsk.jdwp.ReferenceType.Instances.instances001;
79
80 import java.io.*;
81 import nsk.share.Consts;
82 import nsk.share.jdwp.*;
83 import nsk.share.jpda.AbstractDebuggeeTest;
140 setSuccess(false);
141 log.complain("Caught exception while testing JDWP command: " + e);
142 e.printStackTrace(log.getOutStream());
143 }
144 }
145
146 public void doTest() {
147 // force GC in debuggee VM to avoid collection of weak references during test execution
148 forceGC();
149 pipe.println(instances001a.COMMAND_CREATE_TEST_INSTANCES);
150
151 if (!isDebuggeeReady())
152 return;
153
154 int expectedInstances = instances001a.expectedCount;
155
156 String testClassName = nsk.jdwp.ReferenceType.Instances.instances001.TestClass.class.getName();
157
158 long typeID = debuggee.getReferenceTypeID(createTypeSignature(testClassName));
159
160 // Note! This test is broken, in the sense that it incorrectly assumes
161 // that no GC can happen before it walks the heap. In practice, it seems
162 // to only affect this test when using ZGC. However, this test will also
163 // fail when using other GCs if an explicit GC is done here.
164
165 // create command with maxInstances=1, only 1 instance should be returned
166 testClass(typeID, 1, 1, false, 0);
167 // create command with maxInstances=0, all instances should be returned
168 testClass(typeID, 0, expectedInstances, false, 0);
169 // create command with maxInstances=Integer.MAX_VALUE, all instances should be returned
170 testClass(typeID, Integer.MAX_VALUE, expectedInstances, false, 0);
171
172 // create command with maxInstances < 0, expect ILLEGAL_ARGUMENT error
173 testClass(typeID, -1, expectedInstances, true, JDWP.Error.ILLEGAL_ARGUMENT);
174
175 // create command with typeID = 1, expect INVALID_OBJECT error
176 testClass(-1, Integer.MAX_VALUE, expectedInstances, true, JDWP.Error.INVALID_OBJECT);
177
178 // create command with threadID instead of referenceTypeID, expect INVALID_CLASS error
179 testClass(debuggee.getThreadID("main"), Integer.MAX_VALUE, expectedInstances, true, JDWP.Error.INVALID_CLASS);
180
181 // if GC occurs during test the results should be ignored
182 resetStatusIfGC();
183 }
|