Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.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.resume;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdi.*;2829/**30* This class is used as debuggee application for the resume005 JDI test.31*/3233public class resume005a {3435//----------------------------------------------------- template section36static int testCase = -1;3738static final int PASSED = 0;39static final int FAILED = 2;40static final int PASS_BASE = 95;4142static ArgumentHandler argHandler;43static Log log;4445//-------------------------------------------------- log procedures4647private static void log1(String message) {48log.display("**> debuggee: " + message);49}5051private static void logErr(String message) {52log.complain("**> debuggee: " + message);53}5455//====================================================== test program5657static resume005aTestClass tcObject = new resume005aTestClass();5859//------------------------------------------------------ common section60static int instruction = 1;61static int end = 0;62// static int quit = 0;63// static int continue = 2;64static int maxInstr = 1; // 2;6566static int lineForComm = 2;6768private static void methodForCommunication() {69int i1 = instruction;70int i2 = i1;71int i3 = i2;72}73//---------------------------------------------------- main method7475public static void main (String argv[]) {7677argHandler = new ArgumentHandler(argv);78log = argHandler.createDebugeeLog();7980log1("debuggee started!");8182int exitCode = PASSED;838485label0:86for (int i = 0; ; i++) {8788if (instruction > maxInstr) {89logErr("ERROR: unexpected instruction: " + instruction);90exitCode = FAILED;91break ;92}9394log1("methodForCommunication(); : " + i);95methodForCommunication();9697switch (i) {9899//------------------------------------------------------ section tested100101case 0:102resume005aTestClass.method();103waitForTestCase(0);104break;105106case 1: resume005aTestClass.method();107break;108109case 2: resume005aTestClass.method();110111//------------------------------------------------- standard end section112113default:114instruction = end;115methodForCommunication();116break label0;117}118}119120log1("debuggee exits");121System.exit(exitCode + PASS_BASE);122}123124public static void nullMethod() {125throw new NullPointerException("test");126}127// Synchronize with debugger progression.128static void waitForTestCase(int t) {129while (testCase < t) {130try {131Thread.sleep(100);132} catch (InterruptedException e) {133// ignored134}135}136}137}138139class resume005aTestClass {140141static int breakpointLine = 3;142static String awFieldName = "var1";143static String mwFieldName = "var2";144145static int var1 = 0;146static int var2 = 0;147static int var3 = 0;148149static void method () {150var1 = 1;151var3 = var1;152var2 = var3;153try {154resume005a.nullMethod();155} catch ( NullPointerException e ) {156// suspendpolicy005a.log3(" NullPointerException : " + e);157}158}159}160161162