Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.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 resume010 JDI test.31*/3233public class resume010a {3435//----------------------------------------------------- template section3637static final int PASSED = 0;38static final int FAILED = 2;39static final int PASS_BASE = 95;4041static ArgumentHandler argHandler;42static Log log;4344//-------------------------------------------------- log procedures4546private static void log1(String message) {47log.display("**> debuggee: " + message);48}4950private static void logErr(String message) {51log.complain("**> debuggee: " + message);52}5354//====================================================== test program5556static resume010aTestClass tcObject = new resume010aTestClass();5758//------------------------------------------------------ common section5960static int exitCode = PASSED;6162static int testCase = -1;63static int instruction = 1;64static int end = 0;65// static int quit = 0;66// static int continue = 2;67static int maxInstr = 1; // 2;6869static int lineForComm = 2;7071private static void methodForCommunication() {72int i1 = instruction;73int i2 = i1;74int i3 = i2;75}76//---------------------------------------------------- main method7778public static void main (String argv[]) {7980argHandler = new ArgumentHandler(argv);81log = argHandler.createDebugeeLog();8283log1("debuggee started!");8485label0: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:102resume010aTestClass.method();103// Wait for debugger to complete the first test case104// before advancing to the first breakpoint105waitForTestCase(0);106break;107108case 1: resume010aTestClass.method();109break;110111case 2: resume010aTestClass.method();112113//------------------------------------------------- standard end section114115default:116instruction = end;117methodForCommunication();118break label0;119}120}121122System.exit(exitCode + PASS_BASE);123}124// Synchronize with debugger progression.125static void waitForTestCase(int t) {126while (testCase < t) {127try {128Thread.sleep(100);129} catch (InterruptedException e) {130// ignored131}132}133}134}135class resume010aTestClass {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