Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ObjectReference/InvokeMethod/invokemeth001a.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*/2223// THIS TEST IS LINE NUMBER SENSITIVE2425package nsk.jdwp.ObjectReference.InvokeMethod;2627import nsk.share.*;28import nsk.share.jpda.*;29import nsk.share.jdwp.*;3031import java.io.*;3233/**34* This class represents debuggee part in the test.35*/36public class invokemeth001a {3738// name of the tested thread39public static final String THREAD_NAME = "testedThread";4041// line nunber for breakpoint42public static final int BREAKPOINT_LINE_NUMBER = 90;4344// initial and final value of variable changed by the method invoked from debugger45public static final int INITIAL_VALUE = 10;46public static final int FINAL_VALUE = 1234;4748// scaffold objects49private static volatile ArgumentHandler argumentHandler = null;50private static volatile Log log = null;5152public static void main(String args[]) {53invokemeth001a _invokemeth001a = new invokemeth001a();54System.exit(invokemeth001.JCK_STATUS_BASE + _invokemeth001a.runIt(args, System.err));55}5657public int runIt(String args[], PrintStream out) {58//make log for debugee messages59argumentHandler = new ArgumentHandler(args);60log = new Log(out, argumentHandler);6162// create tested of tested class63log.display("Creating object of tested class");64TestedObjectClass.object = new TestedObjectClass();65log.display(" ... object created");6667// invoke method with breakpoint68TestedObjectClass.run();6970log.display("Debugee PASSED");71return invokemeth001.PASSED;72}7374// tested object class75public static class TestedObjectClass {7677// tested object value78public static volatile TestedObjectClass object = null;7980// result of invoking tested mathod81public static volatile int result = INITIAL_VALUE;8283// start the thread and suspend on breakpoint84public static void run() {85log.display("Tested thread: started");8687log.display("Breakpoint line reached");88// next line is for breakpoint89int foo = 0; // BREAKPOINT_LINE_NUMBER90log.display("Breakpoint line passed");9192log.display("Tested thread: finished");93}9495// tested method for invokation from debugger96public int testedMethod(int arg) {97log.display("Tested method invoked with argument:" + arg);98int old = result;99result = arg;100log.display("Tested method returned with result:" + old);101return old;102}103104}105106}107108109