Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001a.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.putProperty;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829/**30* This class is used as debuggee application for the putproperty001 JDI test.31*/3233public class putproperty001a {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 Thread1putproperty001a thread1 = null;5758static TestClass11 obj = new TestClass11();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 Thread1putproperty001a("thread1");103104synchronized (lockObj) {105threadStart(thread1);106log1("methodForCommunication();----");107methodForCommunication();108}109i++;110111case 1:112break;113case 2:114break;115case 3:116break;117case 4:118break;119case 5:120break;121case 6:122break;123case 7:124break;125case 8:126break;127case 9:128break;129case 10:130break;131case 11:132break;133134//------------------------------------------------- standard end section135136default:137instruction = end;138break;139}140141142log1("methodForCommunication();");143methodForCommunication();144if (instruction == end)145break;146147148}149150log1("debuggee exits");151System.exit(exitCode + PASS_BASE);152}153154static Object lockObj = new Object();155static Object waitnotifyObj = new Object();156157static int threadStart(Thread t) {158synchronized (waitnotifyObj) {159t.start();160try {161waitnotifyObj.wait();162} catch ( Exception e) {163exitCode = FAILED;164logErr(" Exception : " + e );165return FAILED;166}167}168return PASSED;169}170}171172class TestClass10{173174static int var101 = 0;175static int var102 = 0;176static int var103 = 0;177178static void method10 () {179putproperty001a.log1("entered: method10");180var101 = 1;181var103 = var101;182var102 = var103;183184}185}186class TestClass11 extends TestClass10{187188static int var111 = 0;189static int var112 = 0;190static int var113 = 0;191192static void method11 () {193putproperty001a.log1("entered: method11");194var101 = 1;195var103 = var101;196var102 = var103;197198var111 = 1;199var113 = var111;200var112 = var113;201}202}203204class Thread1putproperty001a extends Thread {205206String tName = null;207208public Thread1putproperty001a(String threadName) {209super(threadName);210tName = threadName;211}212213public void run() {214putproperty001a.log1(" 'run': enter :: threadName == " + tName);215synchronized(putproperty001a.waitnotifyObj) {216putproperty001a.waitnotifyObj.notify();217}218synchronized(putproperty001a.lockObj) {219TestClass11.method11();220}221putproperty001a.log1(" 'run': exit :: threadName == " + tName);222return;223}224}225226227