Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetEnv/GetEnv001/GetEnv001.java
40951 views
/*1* Copyright (c) 2007, 2020, 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*/222324/*25* @test26*27* @summary converted from VM Testbase nsk/jvmti/GetEnv/GetEnv001.28* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, feature_jdk6_jpda, vm6]29* VM Testbase readme:30* DESCRIPTION31* The test performs a check whether JNI GetEnv function returns a valid JVMTI32* interface instance.33* The check consists of the following steps:34* 1) specific version (1.1) of the JVMTI interface is aquired35* 2) RetransformClasses event (introduced in 1.1) handler is enabled, so36* if the JVMTI interface doesn't support it, the test will fail37* COMMENTS38*39* @library /vmTestbase40* /test/lib41* @run main/othervm/native -agentlib:GetEnv001 nsk.jvmti.GetEnv.GetEnv001.GetEnv00142*/4344package nsk.jvmti.GetEnv.GetEnv001;4546import nsk.share.Consts;47import java.io.PrintStream;4849public class GetEnv001 {50native private static int getLoadedClassesCount();5152public static void main(String args[]) {53args = nsk.share.jvmti.JVMTITest.commonInit(args);5455// JCK-compatible exit56System.exit(run(args, System.out) + Consts.JCK_STATUS_BASE);57}5859/** run test from JCK-compatible environment */60public static int run(String args[], PrintStream out) {61int loadedClasses = getLoadedClassesCount();6263if (loadedClasses > 0) {64out.println("TEST PASSED. The number of loaded classes: "+loadedClasses);65return Consts.TEST_PASSED;66} else {67out.println("TEST FAILED. The number of loaded classes: "+loadedClasses);68return Consts.TEST_FAILED;69}70}71}727374