Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002a.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.EventRequestManager.createStepRequest;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829/**30* This class is used as debuggee application for the crstepreq002 JDI test.31*/3233public class crstepreq002a {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 procedures4546public static void log1(String message) {47log.display("**> debuggee: " + message);48}4950private static void logErr(String message) {51log.complain("**> debuggee: " + message);52}5354//====================================================== test program5556static Thread1crstepreq002a thread1 = null;5758static TestClass10 obj = new TestClass10();5960//------------------------------------------------------ common section6162static int exitCode = PASSED;6364static int instruction = 1;65static int end = 0;66// static int quit = 0;67// static int continue = 2;68static int maxInstr = 1; // 2;6970static int lineForComm = 2;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!");8586label0:87for (int i = 0; ; i++) {8889if (instruction > maxInstr) {90logErr("ERROR: unexpected instruction: " + instruction);91exitCode = FAILED;92break ;93}9495switch (i) {9697//------------------------------------------------------ section tested9899case 0:100thread1 = new Thread1crstepreq002a("thread1");101102synchronized (lockObj) {103threadStart(thread1);104log1("methodForCommunication();----");105methodForCommunication();106}107108//------------------------------------------------- standard end section109110default:111instruction = end;112methodForCommunication();113break label0;114}115}116117log1("debuggee exits");118System.exit(exitCode + PASS_BASE);119}120121static Object lockObj = new Object();122static Object waitnotifyObj = new Object();123124static int threadStart(Thread t) {125synchronized (waitnotifyObj) {126t.start();127try {128waitnotifyObj.wait();129} catch ( Exception e) {130exitCode = FAILED;131logErr(" Exception : " + e );132return FAILED;133}134}135return PASSED;136}137}138139class TestClass10{140static void m10() {141crstepreq002a.log1("entered: m10");142}143}144class TestClass11 extends TestClass10{145static void m11() {146crstepreq002a.log1("entered: m11");147TestClass10.m10();148}149}150151class Thread1crstepreq002a extends Thread {152153String tName = null;154155public Thread1crstepreq002a(String threadName) {156super(threadName);157tName = threadName;158}159160public void run() {161crstepreq002a.log1(" 'run': enter :: threadName == " + tName);162synchronized(crstepreq002a.waitnotifyObj) {163crstepreq002a.waitnotifyObj.notify();164}165synchronized(crstepreq002a.lockObj) {166TestClass11.m11();167}168crstepreq002a.log1(" 'run': exit :: threadName == " + tName);169return;170}171}172173174