Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/classes/classes001/classes001.java
40952 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/classes/classes001.28* VM Testbase keywords: [jpda, jdb]29* VM Testbase readme:30* DECSRIPTION31* A positive test case for the 'classes' command.32* The test checks if jdb correctly replies on 'classes' command.33* The test passes when reply contains full names of all checked classes.34* COMMENTS35*36* @library /vmTestbase37* /test/lib38* @build nsk.jdb.classes.classes001.classes001a39* @run main/othervm40* nsk.jdb.classes.classes001.classes00141* -arch=${os.family}-${os.simpleArch}42* -waittime=543* -debugee.vmkind=java44* -transport.address=dynamic45* -jdb=${test.jdk}/bin/jdb46* -java.options="${test.vm.opts} ${test.java.opts}"47* -workdir=.48* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"49*/5051package nsk.jdb.classes.classes001;5253import nsk.share.*;54import nsk.share.jdb.*;5556import java.io.*;57import java.util.*;5859public class classes001 extends JdbTest {6061public static void main (String argv[]) {62System.exit(run(argv, System.out) + JCK_STATUS_BASE);63}6465public static int run(String argv[], PrintStream out) {66debuggeeClass = DEBUGGEE_CLASS;67firstBreak = FIRST_BREAK;68lastBreak = LAST_BREAK;69return new classes001().runTest(argv, out);70}7172static final String PACKAGE_NAME = "nsk.jdb.classes.classes001";73static final String TEST_CLASS = PACKAGE_NAME + ".classes001";74static final String DEBUGGEE_CLASS = TEST_CLASS + "a";75static final String FIRST_BREAK = DEBUGGEE_CLASS + ".main";76static final String LAST_BREAK = DEBUGGEE_CLASS + ".lastBreak";77static final String NOT_VALID_SAMPLE = "is not a valid";7879static String[] checkedClasses = {80DEBUGGEE_CLASS,81DEBUGGEE_CLASS + "$Inner1",82DEBUGGEE_CLASS + "$Inner2",83DEBUGGEE_CLASS + "$Inner3",84DEBUGGEE_CLASS + "$Inner4",85DEBUGGEE_CLASS + "$Inner5",86DEBUGGEE_CLASS + "$Inner6",87DEBUGGEE_CLASS + "$Inner7",88DEBUGGEE_CLASS + "$Inner8",89DEBUGGEE_CLASS + "$InnerInt1",90DEBUGGEE_CLASS + "$InnerInt2",91DEBUGGEE_CLASS + "$InnerInt3",92DEBUGGEE_CLASS + "$InnerInt4",93DEBUGGEE_CLASS + "$InnerInt5",94PACKAGE_NAME + ".Outer1",95PACKAGE_NAME + ".Outer2",96PACKAGE_NAME + ".Outer3",97PACKAGE_NAME + ".OuterInt1",98PACKAGE_NAME + ".OuterInt2"99};100101/* ------------------------------------- */102103protected void runCases() {104String[] reply;105Paragrep grep;106int count;107Vector v;108String found;109110jdb.setBreakpointInMethod(LAST_BREAK);111reply = jdb.receiveReplyFor(JdbCommand.cont);112113reply = jdb.receiveReplyFor(JdbCommand.classes);114115for (int i = 0; i < checkedClasses.length; i++) {116if (!checkClass(checkedClasses[i], reply)) {117success = false;118}119}120121jdb.contToExit(1);122}123124private boolean checkClass (String className, String[] reply) {125Paragrep grep;126String found;127boolean result = true;128129grep = new Paragrep(reply);130found = grep.findFirst(className);131if (found.length() == 0) {132log.complain("Failed to report class " + className);133result = false;134}135return result;136}137}138139140