Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Breakpoint/breakpoint001.java
40948 views
/*1* Copyright (c) 2003, 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.jvmti.Breakpoint;2425import java.io.*;2627import nsk.share.*;28import nsk.share.jvmti.*;2930/**31* This test exercises the JVMTI event <code>Breakpoint</code>.32* <br>It verifies that thread info, method info and location of33* received Breakpoint events will be the same with two breakpoints34* previously set on the methods <code>bpMethod()</code> and35* <code>bpMethod2()</code> via the function SetBreakpoint().36*/37public class breakpoint001 {38static {39try {40System.loadLibrary("breakpoint001");41} catch (UnsatisfiedLinkError ule) {42System.err.println("Could not load \"breakpoint001\" library");43System.err.println("java.library.path:"44+ System.getProperty("java.library.path"));45throw ule;46}47}4849native int check();5051public static void main(String[] argv) {52argv = nsk.share.jvmti.JVMTITest.commonInit(argv);5354// produce JCK-like exit status55System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);56}5758public static int run(String argv[], PrintStream out) {59return new breakpoint001().runThis(argv, out);60}6162private int runThis(String argv[], PrintStream out) {63ArgumentHandler argHandler = new ArgumentHandler(argv);64Log log = new Log(out, argHandler);65Thread.currentThread().setName("breakpoint001Thr");6667log.display("\nReaching a breakpoint method ...\n");68bpMethod();69log.display("The breakpoint method leaved ...");7071return check();72}7374/**75* dummy method used only to reach breakpoint set in the agent76*/77private void bpMethod() {78int dummyVar = bpMethod2();79}8081/**82* dummy method used only to reach breakpoint set in the agent83*/84private int bpMethod2() {85return 0;86}87}888990