Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/fields/fields001/fields001.java
40955 views
/*1* Copyright (c) 2002, 2020, 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*/222324/*25* @test26*27* @summary converted from VM Testbase nsk/jdb/fields/fields001.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* A positive test for the 'fields <class id>' command.32* There are three test cases:33* - request for the fields defined in class,34* - request for the fields defined in inner class,35* - request for the fields inherited from super class.36* The test passes when reply contains names of all checked fields37* for a given debuggee's class.38* COMMENTS39*40* @library /vmTestbase41* /test/lib42* @build nsk.jdb.fields.fields001.fields001a43* @run main/othervm44* nsk.jdb.fields.fields001.fields00145* -arch=${os.family}-${os.simpleArch}46* -waittime=547* -debugee.vmkind=java48* -transport.address=dynamic49* -jdb=${test.jdk}/bin/jdb50* -java.options="${test.vm.opts} ${test.java.opts}"51* -workdir=.52* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"53*/5455package nsk.jdb.fields.fields001;5657import nsk.share.*;58import nsk.share.jdb.*;5960import java.io.*;61import java.util.*;6263public class fields001 extends JdbTest {6465public static void main (String argv[]) {66System.exit(run(argv, System.out) + JCK_STATUS_BASE);67}6869public static int run(String argv[], PrintStream out) {70debuggeeClass = DEBUGGEE_CLASS;71firstBreak = FIRST_BREAK;72lastBreak = LAST_BREAK;73return new fields001().runTest(argv, out);74}7576static final String PACKAGE_NAME = "nsk.jdb.fields.fields001";77static final String TEST_CLASS = PACKAGE_NAME + ".fields001";78static final String DEBUGGEE_CLASS = TEST_CLASS + "a";79static final String DEBUGGEE_CLASS1 = DEBUGGEE_CLASS + "$Inner";80static final String DEBUGGEE_CLASS2 = DEBUGGEE_CLASS + "$Extender";81static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";82static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";83static final String NOT_VALID_SAMPLE = "is not a valid";8485static String[] checkedFields1 = {86"i_st", "o_st",87"i_pv", "o_pv",88"i_pt", "o_pt",89"i_pb", "o_pb",90"i_fn", "o_fn",91"i_tr", "o_tr",92"i_vl", "o_vl",93"i_a", "o_a",94"i_aa", "o_aa",95"i_aaa", "o_aaa"96};9798static String[] checkedFields2 = {99"ii_pv", "oi_pv",100"ii_pt", "oi_pt",101"ii_pb", "oi_pb",102"ii_fn", "oi_fn",103"ii_tr", "oi_tr",104"ii_vl", "oi_vl",105"ii_a", "oi_a",106"ii_aa", "oi_aa",107"ii_aaa", "oi_aaa"108};109110protected void runCases() {111String[] reply;112Paragrep grep;113int count;114Vector v;115String found;116117jdb.setBreakpointInMethod(LAST_BREAK);118reply = jdb.receiveReplyFor(JdbCommand.cont);119120reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS);121if (!checkFields(DEBUGGEE_CLASS, reply, checkedFields1)) {122success = false;123}124125reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS1);126if (!checkFields(DEBUGGEE_CLASS1, reply, checkedFields2)) {127success = false;128}129130reply = jdb.receiveReplyFor(JdbCommand.fields + DEBUGGEE_CLASS2);131if (!checkFields(DEBUGGEE_CLASS2, reply, checkedFields2)) {132success = false;133}134135jdb.contToExit(1);136}137138private boolean checkFields (String className, String[] reply, String[] checkedFields) {139Paragrep grep;140String found;141boolean result = true;142int count;143144grep = new Paragrep(reply);145for (int i = 0; i < checkedFields.length; i++) {146count = grep.find(checkedFields[i]);147if (count == 0) {148log.complain("Failed to report field " + checkedFields[i] + " for class " + className);149result = false;150}151}152return result;153}154}155156157