Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/StackFrame/PopFrames/popframes001a.java
41162 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*/2223// THIS TEST IS LINE NUMBER SENSITIVE2425package nsk.jdwp.StackFrame.PopFrames;2627import nsk.share.*;28import nsk.share.jpda.*;29import nsk.share.jdwp.*;3031import java.io.*;3233/**34* This class represents debuggee part in the test.35*/36public class popframes001a {3738// name of the tested thread39public static final String THREAD_NAME = "testedThread";4041// line nunber for breakpoint42public static final int BREAKPOINT_LINE_NUMBER = 113;4344// scaffold objects45private static volatile ArgumentHandler argumentHandler = null;46private static volatile Log log = null;4748public static void main(String args[]) {49popframes001a _popframes001a = new popframes001a();50System.exit(popframes001.JCK_STATUS_BASE + _popframes001a.runIt(args, System.err));51}5253public int runIt(String args[], PrintStream out) {54//make log for debugee messages55argumentHandler = new ArgumentHandler(args);56log = new Log(out, argumentHandler);5758// create tested thread59log.display("Creating testing thread");60TestedThreadClass thread = new TestedThreadClass(THREAD_NAME);61log.display(" ... thread created");6263// start tested thread64log.display("Starting tested thread");65thread.start();66log.display(" ... thread started");6768// wait for tested thread finished69try {70log.display("Waiting for tested thread finished");71thread.join();72log.display(" ... thread finished");73} catch(InterruptedException e) {74log.complain("Interruption while waiting for tested thread finished:\n\t" + e);75log.display("Debugee FAILED");76return popframes001.FAILED;77}7879log.display("Debugee PASSED");80return popframes001.PASSED;81}8283// tested thread class84public static class TestedThreadClass extends Thread {8586// number of invokations of tested method87public static volatile int invokations = 0;8889public TestedThreadClass(String name) {90super(name);91}9293// invoke tested method94public void run() {95log.display("Tested thread: started");9697// invoke tested method98int foo = 100;99foo = testedMethod(foo);100101log.display("Tested thread: finished");102}103104// tested method to pop frames105public int testedMethod(int arg) {106invokations++;107log.display("Tested method invoked " + invokations + " time");108int boo = 0;109110log.display("Breakpoint line reached");111// next line is for breakpoint112boo = arg * 2; // BREAKPOINT_LINE_NUMBER113log.display("Breakpoint line passed");114115return boo;116}117}118}119120121