Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.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.jdi.EventSet.resume;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829/**30* This class is used as debuggee application for the resume004 JDI test.31*/3233public class resume004a {3435//----------------------------------------------------- template section36static int testCase = -1;3738static final int PASSED = 0;39static final int FAILED = 2;40static final int PASS_BASE = 95;4142static ArgumentHandler argHandler;43static Log log;4445//-------------------------------------------------- log procedures4647private static void log1(String message) {48log.display("**> debuggee: " + message);49}5051private static void logErr(String message) {52log.complain("**> debuggee: " + message);53}5455//====================================================== test program5657static resume004aTestClass tcObject = new resume004aTestClass();5859//------------------------------------------------------ common section60static int instruction = 1;61static int end = 0;62// static int quit = 0;63// static int continue = 2;64static int maxInstr = 1; // 2;6566static int lineForComm = 2;6768private static void methodForCommunication() {69int i1 = instruction;70int i2 = i1;71int i3 = i2;72}73//---------------------------------------------------- main method7475public static void main (String argv[]) {7677argHandler = new ArgumentHandler(argv);78log = argHandler.createDebugeeLog();7980log1("debuggee started!");8182int exitCode = PASSED;838485label0:86for (int i = 0; ; i++) {8788if (instruction > maxInstr) {89logErr("ERROR: unexpected instruction: " + instruction);90exitCode = FAILED;91break ;92}9394log1("methodForCommunication(); : " + i);95methodForCommunication();9697switch (i) {9899//------------------------------------------------------ section tested100101case 0:102resume004aTestClass.method();103waitForTestCase(0);104break;105106case 1: resume004aTestClass.method();107break;108109case 2: resume004aTestClass.method();110111//------------------------------------------------- standard end section112113default:114instruction = end;115methodForCommunication();116break label0;117}118}119120log1("debuggee exits");121System.exit(exitCode + PASS_BASE);122}123// Synchronize with debugger progression.124static void waitForTestCase(int t) {125while (testCase < t) {126try {127Thread.sleep(100);128} catch (InterruptedException e) {129// ignored130}131}132}133}134135class resume004aTestClass {136137static int breakpointLine = 3;138static String awFieldName = "var1";139static String mwFieldName = "var2";140141static int var1 = 0;142static int var2 = 0;143static int var3 = 0;144145static void method () {146var1 = 1;147var3 = var1;148var2 = var3;149}150}151152153