Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002a.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.EventRequest.setEnabled;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829/**30* This class is used as debuggee application for the setenabled002 JDI test.31*/3233public class setenabled002a {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 setenabled002aThread1 thread1 = null;5758static setenabled002aTestClass11 obj = new setenabled002aTestClass11();5960static NullPointerException excObj = new NullPointerException();6162//------------------------------------------------------ common section6364static int exitCode = PASSED;6566static int instruction = 1;67static int end = 0;68// static int quit = 0;69// static int continue = 2;70static int maxInstr = 1; // 2;7172static int lineForComm = 2;7374private static void methodForCommunication() {75int i1 = instruction;76int i2 = i1;77int i3 = i2;78}79//---------------------------------------------------- main method8081public static void main (String argv[]) {8283argHandler = new ArgumentHandler(argv);84log = argHandler.createDebugeeLog();8586log1("debuggee started!");8788label0:89for (int i = 0; ; i++) {9091if (instruction > maxInstr) {92logErr("ERROR: unexpected instruction: " + instruction);93exitCode = FAILED;94break ;95}9697switch (i) {9899//------------------------------------------------------ section tested100101case 0:102thread1 = new setenabled002aThread1("thread1");103104synchronized (lockObj) {105threadStart(thread1);106log1("methodForCommunication();----");107methodForCommunication();108}109try {110thread1.join();111log1("methodForCommunication();----2");112methodForCommunication();113} catch ( InterruptedException e ) {114}115i++;116117case 1:118break;119case 2:120break;121case 3:122break;123case 4:124break;125case 5:126break;127case 6:128break;129case 7:130break;131case 8:132break;133case 9:134break;135case 10:136break;137case 11:138break;139140//------------------------------------------------- standard end section141142default:143instruction = end;144break;145}146147148log1("methodForCommunication();");149methodForCommunication();150if (instruction == end)151break;152153154}155156log1("debuggee exits");157System.exit(exitCode + PASS_BASE);158}159160static Object lockObj = new Object();161static Object waitnotifyObj = new Object();162163static int threadStart(Thread t) {164synchronized (waitnotifyObj) {165t.start();166try {167waitnotifyObj.wait();168} catch ( Exception e) {169exitCode = FAILED;170logErr(" Exception : " + e );171return FAILED;172}173}174return PASSED;175}176}177178class setenabled002aTestClass10{179180static int var101 = 0;181static int var102 = 0;182static int var103 = 0;183184static void method10 () {185setenabled002a.log1("entered: method10");186var101 = 1;187var103 = var101;188var102 = var103;189190}191}192class setenabled002aTestClass11 extends setenabled002aTestClass10{193194static int var111 = 0;195static int var112 = 0;196static int var113 = 0;197198static void method11 () {199setenabled002a.log1("entered: method11");200var101 = 1;201var103 = var101;202var102 = var103;203204var111 = 1;205var113 = var111;206var112 = var113;207}208}209210class setenabled002aThread1 extends Thread {211212String tName = null;213214public setenabled002aThread1(String threadName) {215super(threadName);216tName = threadName;217}218219public void run() {220setenabled002a.log1(" 'run': enter :: threadName == " + tName);221synchronized(setenabled002a.waitnotifyObj) {222setenabled002a.waitnotifyObj.notify();223}224synchronized(setenabled002a.lockObj) {225setenabled002aTestClass11.method11();226}227setenabled002a.log1(" 'run': exit :: threadName == " + tName);228return;229}230}231232233