Path: blob/master/test/hotspot/jtreg/serviceability/jvmti/GetLocalVariable/GetLocalVars.java
41153 views
/*1* Copyright (c) 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/*24* @test25* @bug 808040626* @summary VM_GetOrSetLocal doesn't check local slot type against requested type27* @requires vm.jvmti28* @compile GetLocalVars.java29* @run main/othervm/native -Xcomp -agentlib:GetLocalVars GetLocalVars30*/313233public class GetLocalVars {34private static final String agentLib = "GetLocalVars";3536static native void testLocals(Thread thread);37static native int getStatus();3839public static40void main(String[] args) throws Exception {41try {42System.loadLibrary(agentLib);43} catch (UnsatisfiedLinkError ex) {44System.err.println("Failed to load " + agentLib + " lib");45System.err.println("java.library.path: " + System.getProperty("java.library.path"));46throw ex;47}48run(args);49int status = getStatus();50if (status != 0) {51throw new RuntimeException("Test GetLocalVars failed with a bad status: " + status);52}53}5455public static56void run(String argv[]) {57GetLocalVars testedObj = new GetLocalVars();58double pi = 3.14d;59byte sym = 'X';60int year = 2018;6162staticMeth(sym, testedObj, pi, year);63}6465public static synchronized66int staticMeth(byte byteArg, Object objArg, double dblArg, int intArg) {67testLocals(Thread.currentThread());68{69int intLoc = 9999;70intArg = intLoc;71}72return intArg;73}74}757677