Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/CapabilitiesNew/capabilitiesnew001.java
41161 views
/*1* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package nsk.jdwp.VirtualMachine.CapabilitiesNew;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdwp.*;2829import java.io.*;30import java.util.*;3132public class capabilitiesnew001 {33static final int JCK_STATUS_BASE = 95;34static final int PASSED = 0;35static final int FAILED = 2;36static final String PACKAGE_NAME = "nsk.jdwp.VirtualMachine.CapabilitiesNew";37static final String TEST_CLASS_NAME = PACKAGE_NAME + "." + "capabilitiesnew001";38static final String DEBUGEE_CLASS_NAME = TEST_CLASS_NAME + "a";3940static final String JDWP_COMMAND_NAME = "VirtualMachine.CapabilitiesNew";41static final int JDWP_COMMAND_ID = JDWP.Command.VirtualMachine.CapabilitiesNew;4243public static void main (String argv[]) {44System.exit(run(argv,System.out) + JCK_STATUS_BASE);45}4647public static int run(String argv[], PrintStream out) {48return new capabilitiesnew001().runIt(argv, out);49}5051public int runIt(String argv[], PrintStream out) {5253boolean success = true;5455try {56ArgumentHandler argumentHandler = new ArgumentHandler(argv);57Log log = new Log(out, argumentHandler);5859try {6061Binder binder = new Binder(argumentHandler, log);62log.display("Start debugee VM");63Debugee debugee = binder.bindToDebugee(DEBUGEE_CLASS_NAME);64Transport transport = debugee.getTransport();65IOPipe pipe = debugee.createIOPipe();6667log.display("Waiting for VM_INIT event");68debugee.waitForVMInit();6970log.display("Querying for IDSizes");71debugee.queryForIDSizes();7273log.display("Resume debugee VM");74debugee.resume();7576log.display("Waiting for command: " + "ready");77String cmd = pipe.readln();78log.display("Received command: " + cmd);7980// begin test of JDWP command8182try {83CommandPacket command = new CommandPacket(JDWP_COMMAND_ID);8485log.display("Sending command packet:\n" + command);86transport.write(command);8788log.display("Waiting for reply packet");89ReplyPacket reply = new ReplyPacket();90transport.read(reply);91log.display("Reply packet received:\n" + reply);9293log.display("Checking reply packet header");94reply.checkHeader(command.getPacketID());9596log.display("Parsing reply packet:");97reply.resetPosition();9899byte canWatchFieldModification = reply.getByte();100log.display(" canWatchFieldModification: "101+ canWatchFieldModification);102103byte canWatchFieldAction = reply.getByte();104log.display(" canWatchFieldAction: "105+ canWatchFieldAction);106107byte canGetBytecodes = reply.getByte();108log.display(" canGetBytecodes: "109+ canGetBytecodes);110111byte canGetSyntheticAttribute = reply.getByte();112log.display(" canGetSyntheticAttribute: "113+ canGetSyntheticAttribute);114115byte canGetOwnedMonitorInfo = reply.getByte();116log.display(" canGetOwnedMonitorInfo: "117+ canGetOwnedMonitorInfo);118119byte canGetCurrentContendedMonitor = reply.getByte();120log.display(" canGetCurrentContendedMonitor: "121+ canGetCurrentContendedMonitor);122123byte canGetMonitorInfo = reply.getByte();124log.display(" canGetMonitorInfo: "125+ canGetMonitorInfo);126127byte canRedefineClasses = reply.getByte();128log.display(" canRedefineClasses: "129+ canRedefineClasses);130131byte canAddMethod = reply.getByte();132log.display(" canAddMethod: "133+ canAddMethod);134135byte canUnrestrictedlyRedefineClasses = reply.getByte();136log.display(" canUnrestrictedlyRedefineClasses: "137+ canUnrestrictedlyRedefineClasses);138139byte canPopFrames = reply.getByte();140log.display(" canPopFrames: "141+ canPopFrames);142143byte canUseInstanceFilters = reply.getByte();144log.display(" canUseInstanceFilters: "145+ canUseInstanceFilters);146147byte canGetSourceDebugExtension = reply.getByte();148log.display(" canGetSourceDebugExtension: "149+ canGetSourceDebugExtension);150151byte canRequestVMDeathEvent = reply.getByte();152log.display(" canRequestVMDeathEvent: "153+ canRequestVMDeathEvent);154155byte canSetDefaultStratum = reply.getByte();156log.display(" canSetDefaultStratum: "157+ canSetDefaultStratum);158159for (int i = 16; i <=32; i++) {160byte reserved = reply.getByte();161log.display(" reserved" + i + ": "162+ reserved);163}164165if (! reply.isParsed()) {166log.complain("Extra bytes in reply packet at: "167+ reply.currentPosition());168success = false;169}170171} catch (Exception e) {172log.complain("Exception catched: " + e);173success = false;174}175176// end test of JDWP command177178log.display("Sending command: " + "quit");179pipe.println("quit");180181log.display("Waiting for debugee exits");182int code = debugee.waitFor();183if (code == JCK_STATUS_BASE + PASSED) {184log.display("Debugee PASSED: " + code);185} else {186log.complain("Debugee FAILED: " + code);187success = false;188}189190} catch (Exception e) {191log.complain("Unexpected exception: " + e);192e.printStackTrace(out);193success = false;194}195196if (!success) {197log.complain("TEST FAILED");198return FAILED;199}200201} catch (Exception e) {202out.println("Unexpected exception: " + e);203e.printStackTrace(out);204out.println("TEST FAILED");205return FAILED;206}207208out.println("TEST PASSED");209return PASSED;210211}212213}214215216