Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008a.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.suspendPolicy;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829/**30* This class is used as debuggee application for the suspendpolicy008 JDI test.31*/3233public class suspendpolicy008a {3435//----------------------------------------------------- templete 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 Threadsuspendpolicy008a thread0 = null;57static Threadsuspendpolicy008a thread1 = null;58static Threadsuspendpolicy008a thread2 = null;59static Threadsuspendpolicy008a thread3 = null;60static Threadsuspendpolicy008a thread4 = null;61static Threadsuspendpolicy008a thread5 = null;62static Threadsuspendpolicy008a thread6 = null;6364//------------------------------------------------------ common section6566static int exitCode = PASSED;6768static int instruction = 1;69static int end = 0;70// static int quit = 0;71// static int continue = 2;72static int maxInstr = 1; // 2;7374static int lineForComm = 2;7576private static void methodForCommunication() {77int i1 = instruction;78int i2 = i1;79int i3 = i2;80}81//---------------------------------------------------- main method8283public static void main (String argv[]) {8485argHandler = new ArgumentHandler(argv);86log = argHandler.createDebugeeLog();8788log1("debuggee started!");8990int exitCode = PASSED;919293label0:94for (int i = 0; ; i++) {9596if (instruction > maxInstr) {97logErr("ERROR: unexpected instruction: " + instruction);98exitCode = FAILED;99break ;100}101102switch (i) {103104//------------------------------------------------------ section tested105106case 0:107thread0 = new Threadsuspendpolicy008a("thread0");108methodForCommunication();109110threadStart(thread0);111112thread1 = new Threadsuspendpolicy008a("thread1");113methodForCommunication();114break;115116case 1:117threadStart(thread1);118119thread2 = new Threadsuspendpolicy008a("thread2");120methodForCommunication();121break;122123case 2:124threadStart(thread2);125126thread3 = new Threadsuspendpolicy008a("thread3");127methodForCommunication();128break;129130case 3:131threadStart(thread3);132133thread4 = new Threadsuspendpolicy008a("thread4");134methodForCommunication();135break;136137case 4:138threadStart(thread4);139140thread5 = new Threadsuspendpolicy008a("thread5");141methodForCommunication();142break;143144case 5:145threadStart(thread5);146147thread6 = new Threadsuspendpolicy008a("thread6");148methodForCommunication();149break;150151case 6:152threadStart(thread6);153154//------------------------------------------------- standard end section155156default:157instruction = end;158methodForCommunication();159break label0;160}161}162163System.exit(exitCode + PASS_BASE);164}165166static Object waitnotifyObj = new Object();167168static int threadStart(Thread t) {169synchronized (waitnotifyObj) {170t.start();171try {172waitnotifyObj.wait();173} catch ( Exception e) {174exitCode = FAILED;175logErr(" Exception : " + e );176return FAILED;177}178}179return PASSED;180}181182static class Threadsuspendpolicy008a extends Thread {183184String tName = null;185186public Threadsuspendpolicy008a(String threadName) {187super(threadName);188tName = threadName;189}190191public void run() {192log1(" 'run': enter :: threadName == " + tName);193synchronized (waitnotifyObj) {194waitnotifyObj.notify();195}196log1(" 'run': exit :: threadName == " + tName);197return;198}199}200201}202203204