Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java
41161 views
/*1* Copyright (c) 2001, 2019, 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.EventQueue.remove;2425import jdk.test.lib.Utils;26import nsk.share.*;27import nsk.share.jpda.*;28import nsk.share.jdi.*;2930/**31* This class is used as debuggee application for the remove004 JDI test.32*/3334public class remove004a {3536//----------------------------------------------------- templete section3738static 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 program5657//------------------------------------------------------ common section58static int instruction = 1;59static int end = 0;60// static int quit = 0;61// static int continue = 2;62static int maxInstr = 1; // 2;6364static int lineForComm = 2;6566// Used for communication between debugger and debuggee67static volatile boolean stopSleeping = false;6869// Used by debugger to set stopSleeping flag to true70static final boolean BOOLEAN_TRUE_VALUE = true;7172private static void methodForCommunication() {73int i1 = instruction;74int i2 = i1;75int i3 = i2;76}77//---------------------------------------------------- main method7879public static void main (String argv[]) {8081argHandler = new ArgumentHandler(argv);82log = argHandler.createDebugeeLog();8384log1("debuggee started!");8586int exitCode = PASSED;878889label0:90for (int i = 0; ; i++) {9192if (instruction > maxInstr) {93logErr("ERROR: unexpected instruction: " + instruction);94exitCode = FAILED;95break ;96}9798switch (i) {99100//------------------------------------------------------ section tested101102case 0:103log1("before: methodForCommunication();");104methodForCommunication();105log1("before: Thread.sleep");106Utils.waitForCondition(107() -> {108return stopSleeping;109},110Utils.adjustTimeout(argHandler.getWaitTime() * 10000),111100);112log1("after: Thread.sleep");113break ;114115//------------------------------------------------- standard end section116117default:118instruction = end;119methodForCommunication();120break label0;121}122}123124System.exit(exitCode + PASS_BASE);125}126}127128129