< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/InstanceCounts/instanceCounts001/instanceCounts001.java

Print this page




  44  *     and 'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass2' reachable via references with types
  45  *     which should be supported by command VirtualMachine.InstanceCounts:
  46  *         - strong reference
  47  *         - soft reference
  48  *         - weak reference
  49  *         - phantom reference
  50  *         - JNI global reference
  51  *         - JNI local reference
  52  *     First, debugger obtains referenceTypeID for 'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass1'.
  53  *     Then, debugger creates command packet for InstanceCounts command with the found referenceTypeID
  54  *     as an argument, writes packet to the transport      channel, and waits for a reply packet.
  55  *     When reply packet is received, debugger parses the packet structure, extracts number of instances
  56  *     and checks that received value is correct.
  57  *     Then debugger repeat described above actions, but created command packet contains 2 referenceTypeIDs for
  58  *     'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass1' and 'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass2'.
  59  *         Also, test performs check for case when incorrect data is sent in command:
  60  *                 - create command with refTypesCount < 0, expect ILLEGAL_ARGUMENT error
  61  *     Finally, debugger sends debuggee signal to quit, waits for it exits
  62  *     and exits too with the proper exit code.
  63  *

  64  * @library /vmTestbase /test/hotspot/jtreg/vmTestbase
  65  *          /test/lib
  66  * @run driver jdk.test.lib.FileInstaller . .
  67  * @build nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.instanceCounts001
  68  *        nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.instanceCounts001a
  69  * @run main/othervm/native PropertyResolvingWrapper
  70  *      nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.instanceCounts001
  71  *      -arch=${os.family}-${os.simpleArch}
  72  *      -verbose
  73  *      -waittime=5
  74  *      -debugee.vmkind=java
  75  *      -transport.address=dynamic
  76  *      -debugee.vmkeys="-Xmx128M ${test.vm.opts} ${test.java.opts}"
  77  */
  78 
  79 package nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001;
  80 
  81 import java.io.*;
  82 import nsk.share.Consts;
  83 import nsk.share.jdwp.*;


 146             if (!reply.isParsed()) {
 147                 setSuccess(false);
 148                 log.complain("Extra trailing bytes found in reply packet at: " + reply.currentPosition());
 149             }
 150         } catch (Exception e) {
 151             setSuccess(false);
 152             log.complain("Caught exception while testing JDWP command: " + e);
 153             e.printStackTrace(log.getOutStream());
 154         }
 155     }
 156 
 157     public void doTest() {
 158         String testClass1 = nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass1.class.getName();
 159         String testClass2 = nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass2.class.getName();
 160 
 161         forceGC();
 162         pipe.println(instanceCounts001a.COMMAND_CREATE_TEST_INSTANCES);
 163 
 164         if (!isDebuggeeReady())
 165             return;





 166 
 167         int expectedCount = instanceCounts001a.expectedCount;
 168 
 169         String classNames[];
 170 
 171         classNames = new String[] { createTypeSignature(testClass1) };
 172 
 173         long typeIDs[];
 174 
 175         typeIDs = new long[classNames.length];
 176 
 177         // create valid command for 1 class
 178         for (int i = 0; i < classNames.length; i++)
 179             typeIDs[i] = debuggee.getReferenceTypeID(classNames[i]);
 180 
 181         testCommand(typeIDs, typeIDs.length, new int[] { expectedCount }, false, 0);
 182 
 183         classNames = new String[] { createTypeSignature(testClass1), createTypeSignature(testClass2) };
 184 
 185         typeIDs = new long[classNames.length];


  44  *     and 'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass2' reachable via references with types
  45  *     which should be supported by command VirtualMachine.InstanceCounts:
  46  *         - strong reference
  47  *         - soft reference
  48  *         - weak reference
  49  *         - phantom reference
  50  *         - JNI global reference
  51  *         - JNI local reference
  52  *     First, debugger obtains referenceTypeID for 'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass1'.
  53  *     Then, debugger creates command packet for InstanceCounts command with the found referenceTypeID
  54  *     as an argument, writes packet to the transport      channel, and waits for a reply packet.
  55  *     When reply packet is received, debugger parses the packet structure, extracts number of instances
  56  *     and checks that received value is correct.
  57  *     Then debugger repeat described above actions, but created command packet contains 2 referenceTypeIDs for
  58  *     'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass1' and 'nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass2'.
  59  *         Also, test performs check for case when incorrect data is sent in command:
  60  *                 - create command with refTypesCount < 0, expect ILLEGAL_ARGUMENT error
  61  *     Finally, debugger sends debuggee signal to quit, waits for it exits
  62  *     and exits too with the proper exit code.
  63  *
  64  * @requires vm.gc != "Z"
  65  * @library /vmTestbase /test/hotspot/jtreg/vmTestbase
  66  *          /test/lib
  67  * @run driver jdk.test.lib.FileInstaller . .
  68  * @build nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.instanceCounts001
  69  *        nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.instanceCounts001a
  70  * @run main/othervm/native PropertyResolvingWrapper
  71  *      nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.instanceCounts001
  72  *      -arch=${os.family}-${os.simpleArch}
  73  *      -verbose
  74  *      -waittime=5
  75  *      -debugee.vmkind=java
  76  *      -transport.address=dynamic
  77  *      -debugee.vmkeys="-Xmx128M ${test.vm.opts} ${test.java.opts}"
  78  */
  79 
  80 package nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001;
  81 
  82 import java.io.*;
  83 import nsk.share.Consts;
  84 import nsk.share.jdwp.*;


 147             if (!reply.isParsed()) {
 148                 setSuccess(false);
 149                 log.complain("Extra trailing bytes found in reply packet at: " + reply.currentPosition());
 150             }
 151         } catch (Exception e) {
 152             setSuccess(false);
 153             log.complain("Caught exception while testing JDWP command: " + e);
 154             e.printStackTrace(log.getOutStream());
 155         }
 156     }
 157 
 158     public void doTest() {
 159         String testClass1 = nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass1.class.getName();
 160         String testClass2 = nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.TestClass2.class.getName();
 161 
 162         forceGC();
 163         pipe.println(instanceCounts001a.COMMAND_CREATE_TEST_INSTANCES);
 164 
 165         if (!isDebuggeeReady())
 166             return;
 167 
 168         // Note! This test is broken, in the sense that it incorrectly assumes
 169         // that no GC can happen before it walks the heap. In practice, it seems
 170         // to only affect this test when using ZGC. However, this test will also
 171         // fail when using other GCs if an explicit GC is done here.
 172 
 173         int expectedCount = instanceCounts001a.expectedCount;
 174 
 175         String classNames[];
 176 
 177         classNames = new String[] { createTypeSignature(testClass1) };
 178 
 179         long typeIDs[];
 180 
 181         typeIDs = new long[classNames.length];
 182 
 183         // create valid command for 1 class
 184         for (int i = 0; i < classNames.length; i++)
 185             typeIDs[i] = debuggee.getReferenceTypeID(classNames[i]);
 186 
 187         testCommand(typeIDs, typeIDs.length, new int[] { expectedCount }, false, 0);
 188 
 189         classNames = new String[] { createTypeSignature(testClass1), createTypeSignature(testClass2) };
 190 
 191         typeIDs = new long[classNames.length];
< prev index next >