Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdb/regression/b4689395/b4689395.java
40951 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* @bug 468939528* @summary converted from VM Testbase nsk/jdb/regression/b4689395.29* VM Testbase keywords: [jpda, jdb]30* VM Testbase readme:31* DESCRIPTION32* Regression test for the bug33* 4689395 (P4/S3) "step over" after a class is redefined acts like "step out"34* Release summary: 1.435* Hardware version: generic36* O/S version (unbundled products): 5.837* The test consists of two java-files:38* b4689395.java - launches jdb and debuggee, writes commands to jdb,39* reads the jdb output;40* b4689395a.java - the debugged application.41* The debugged application (b4689395a.java) defines method minor() that42* prints four lines into System.out. b4689395 sets a breakpoint on the 54th43* line44* System.out.println("A breakpoint is here.");45* and then redefines b4689395a with newclass/b4689395a. Those classes differ46* just in the 30th line (period is omitted in newclass/b4689395a). After that47* the debuggee invokes 'next' command. The test fails if48* b4689395.ERROR_MESSAGE message appears in output, otherwise the test passes.49* COMMENTS50* The test reproduces the bug on Solsparc.51* java version "1.4.1-beta"52* Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)53* Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)54* Command line55* ../jdk1.4.1-b14/solsparc/bin/java b4689395 -arch=sparc56* -waittime=2 -debugee.vmkind=java57* -jdb=../jdk1.4.1-b14/solsparc/bin/jdb58* -workdir=../b4689395 -jdb.option= -debugee.vmkeys=59* #launcher > Compound prompt found: main[1]60* #Test cases starts.61* #Sending command: stop at b4689395a:5462* #63* #launcher > Compound prompt found: main[1]64* #Sending command: cont65* #66* #launcher > Compound prompt found: main[1]67* #Sending command: redefine b4689395a b4689395/newclass/b4689395a.class68* #69* #launcher > Compound prompt found: main[1]70* #Sending command: next71* #72* #launcher > Compound prompt found: main[1]73* ## ERROR: 'ERROR_M' is not expected to be printed after 'next' command.74* #Sending command: cont75* #76* #Test cases ends.77* #Waiting for jdb exits78* #jdb normally exited79* ## ERROR: TEST FAILED80* #81* #82* ##>83* ##> SUMMARY: Following errors occured84* ##> during test execution:85* ##>86* ## ERROR: 'ERROR_M' is not expected to be printed after 'next' command.87* ## ERROR: TEST FAILED88*89* @library /vmTestbase90* /test/lib91*92* @build nsk.jdb.regression.b4689395.b468939593* nsk.jdb.regression.b4689395.b4689395a94*95* @comment compile newclass/b4689395a.java to newclass96* @run driver97* ExecDriver --cmd98* ${compile.jdk}/bin/javac99* -d ${test.classes}/newclass100* -cp ${test.class.path}101* ${test.src}/newclass/b4689395a.java102*103* @run main/othervm104* nsk.jdb.regression.b4689395.b4689395105* -arch=${os.family}-${os.simpleArch}106* -waittime=5107* -debugee.vmkind=java108* -transport.address=dynamic109* -jdb=${test.jdk}/bin/jdb110* -java.options="${test.vm.opts} ${test.java.opts}"111* -workdir=.112* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"113*/114115package nsk.jdb.regression.b4689395;116117import nsk.share.*;118import nsk.share.jdb.*;119import nsk.share.classload.ClassLoadUtils;120121import java.io.*;122import java.util.*;123124public class b4689395 extends JdbTest {125final static String TEST_CLASS = b4689395.class.getName();126final static String DEBUGGEE_CLASS = TEST_CLASS + "a";127final static String FIRST_BREAK = DEBUGGEE_CLASS + ".main";128final static String ERROR_MESSAGE = "ERROR_M";129final static int LINE_NUMBER = 54;130private String classFile;131132public static void main (String argv[]) {133System.exit(run(argv, System.out) + JCK_STATUS_BASE);134}135136public static int run(String argv[], PrintStream out) {137debuggeeClass = DEBUGGEE_CLASS;138firstBreak = FIRST_BREAK;139return new b4689395().runTest(argv, out);140}141142public b4689395() {143classFile = ClassLoadUtils.getRedefineClassFileName(DEBUGGEE_CLASS);144if (classFile == null)145throw new TestFailure("Unable to find redefine class file in classpath for: " + DEBUGGEE_CLASS);146}147148protected void runCases() {149String[] reply;150reply = jdb.receiveReplyFor(JdbCommand.stop_at + DEBUGGEE_CLASS + ":" + LINE_NUMBER);151reply = jdb.receiveReplyFor(JdbCommand.cont);152153if (new File(classFile).exists()) {154reply = jdb.receiveReplyFor(JdbCommand.redefine + DEBUGGEE_CLASS155+ " " + classFile);156reply = jdb.receiveReplyFor(JdbCommand.next);157158Paragrep grep = new Paragrep(reply);159if (grep.find(ERROR_MESSAGE) != 0) {160log.complain("'" + ERROR_MESSAGE + "' is not expected to be "161+ "printed after 'next' command.");162success = false;163}164} else {165log.complain("File does not exist: " + classFile);166success = false;167}168169jdb.contToExit(1);170}171}172173174