Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocalVariable/isVisible/isvisible001a.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.LocalVariable.isVisible;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;282930/**31* This class is used as debuggee application for the isvisible001 JDI test.32*/3334public class isvisible001a {3536//----------------------------------------------------- templete section3738static final int PASSED = 0;39static final int FAILED = 2;40static final int PASS_BASE = 95;4142//-------------------------------------------------- log procedures4344static boolean verbMode = false;4546public static void log1(String message) {47if (verbMode)48System.err.println("**> mainThread: " + message);49}50public static void log2(String message) {51if (verbMode)52System.err.println("**> " + message);53}5455private static void logErr(String message) {56if (verbMode)57System.err.println("!!**> mainThread: " + message);58}5960//====================================================== test program61//---------------------------------------------------- main method6263public static void main (String argv[]) {6465for (int i=0; i<argv.length; i++) {66if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) {67verbMode = true;68break;69}70}71log1("debuggee started!");7273// informing a debugger of readyness74ArgumentHandler argHandler = new ArgumentHandler(argv);75IOPipe pipe = argHandler.createDebugeeIOPipe();76pipe.println("ready");777879int exitCode = PASSED;80for (int i = 0; ; i++) {8182String instruction;8384log1("waiting for an instruction from the debugger ...");85instruction = pipe.readln();86if (instruction.equals("quit")) {87log1("'quit' recieved");88break ;8990} else if (instruction.equals("newcheck")) {91switch (i) {9293//------------------------------------------------------ section tested9495case 0:96Threadisvisible001a thread2 =97new Threadisvisible001a("Thread2");98log1(" thread2 is created");99100label:101synchronized (Threadisvisible001a.lockingObject) {102synchronized (Threadisvisible001a.waitnotifyObj) {103log1(" synchronized (waitnotifyObj) { enter");104log1(" before: thread2.start()");105thread2.start();106107try {108log1(" before: waitnotifyObj.wait();");109Threadisvisible001a.waitnotifyObj.wait();110log1(" after: waitnotifyObj.wait();");111pipe.println("checkready");112instruction = pipe.readln();113if (!instruction.equals("continue")) {114logErr("ERROR: unexpected instruction: " + instruction);115exitCode = FAILED;116break label;117}118pipe.println("docontinue");119} catch ( Exception e2) {120log1(" Exception e2 exception: " + e2 );121pipe.println("waitnotifyerr");122}123}124}125log1("mainThread is out of: synchronized (lockingObject) {");126127break ;128129//------------------------------------------------- standard end section130131default:132pipe.println("checkend");133break ;134}135136} else {137logErr("ERRROR: unexpected instruction: " + instruction);138exitCode = FAILED;139break ;140}141}142143System.exit(exitCode + PASS_BASE);144}145}146147class Threadisvisible001a extends Thread {148149public Threadisvisible001a(String threadName) {150super(threadName);151}152153public static Object waitnotifyObj = new Object();154public static Object lockingObject = new Object();155156public void run() {157log("method 'run' enter");158synchronized (waitnotifyObj) {159log("entered into block: synchronized (waitnotifyObj)");160waitnotifyObj.notify(); }161log("exited from block: synchronized (waitnotifyObj)");162synchronized (lockingObject) {163log("entered into block: synchronized (lockingObject)"); }164log("exited from block: synchronized (lockingObject)");165log("call to the method 'runt1'");166167int i0 = 0;168runt1();169int i1 = 0;170171log("returned from the method 'runt1'");172log("method 'run' exit");173return;174}175176public void runt1() {177int i2 = 0;178boolean b1 = true;179log("method 'runt1' enter");180log("method 'runt1' body");181log("method 'runt1' exit");182int i3 = 0;183return;184}185186187public static final int breakpointLineNumber1 = 3;188//public static final int breakpointLineNumber3 = 7;189190//public static final int breakpointLineNumber2 = 2;191192void log(String str) {193isvisible001a.log2("thread2: " + str);194}195196}197198199