Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009a.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 suspendpolicy009 JDI test.31*/3233public class suspendpolicy009a {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 Threadsuspendpolicy009a thread0 = null;57static Threadsuspendpolicy009a thread1 = null;58static Threadsuspendpolicy009a thread2 = null;59static Threadsuspendpolicy009a thread3 = null;60static Threadsuspendpolicy009a thread4 = null;61static Threadsuspendpolicy009a thread5 = null;62static Threadsuspendpolicy009a 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 Threadsuspendpolicy009a("thread0");108methodForCommunication();109110threadStart(thread0);111try {112thread0.join();113} catch (InterruptedException e) {114}115thread1 = new Threadsuspendpolicy009a("thread1");116methodForCommunication();117break;118119case 1:120threadStart(thread1);121try {122thread1.join();123} catch (InterruptedException e) {124}125thread2 = new Threadsuspendpolicy009a("thread2");126methodForCommunication();127break;128129case 2:130threadStart(thread2);131try {132thread2.join();133} catch (InterruptedException e) {134}135thread3 = new Threadsuspendpolicy009a("thread3");136methodForCommunication();137break;138139case 3:140threadStart(thread3);141try {142thread3.join();143} catch (InterruptedException e) {144}145thread4 = new Threadsuspendpolicy009a("thread4");146methodForCommunication();147break;148149case 4:150threadStart(thread4);151try {152thread4.join();153} catch (InterruptedException e) {154}155thread5 = new Threadsuspendpolicy009a("thread5");156methodForCommunication();157break;158159case 5:160threadStart(thread5);161try {162thread5.join();163} catch (InterruptedException e) {164}165thread6 = new Threadsuspendpolicy009a("thread6");166methodForCommunication();167break;168169case 6:170threadStart(thread6);171try {172thread6.join();173} catch (InterruptedException e) {174}175//------------------------------------------------- standard end section176177default:178instruction = end;179methodForCommunication();180break label0;181}182}183184System.exit(exitCode + PASS_BASE);185}186187static Object waitnotifyObj = new Object();188189static int threadStart(Thread t) {190synchronized (waitnotifyObj) {191t.start();192try {193waitnotifyObj.wait();194} catch ( Exception e) {195exitCode = FAILED;196logErr(" Exception : " + e );197return FAILED;198}199}200return PASSED;201}202203static class Threadsuspendpolicy009a extends Thread {204205String tName = null;206207public Threadsuspendpolicy009a(String threadName) {208super(threadName);209tName = threadName;210}211212public void run() {213log1(" 'run': enter :: threadName == " + tName);214synchronized (waitnotifyObj) {215waitnotifyObj.notify();216}217log1(" 'run': exit :: threadName == " + tName);218return;219}220}221222}223224225