Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassLoad/classload001.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.ClassLoad;2425import java.io.*;26import java.util.*;27import nsk.share.*;2829/**30* The test exercises the JVMTI event Class Load.<br>31* It verifies that the event will be sent for the auxiliary class32* <code>TestedClass</code> and array of type <code>TestedClass</code>33* and vise versa for primitive classes and arrays of primitive types34* in accordance with the ClassLoad spec:<br>35* <code>Arrays of non-primitive types have class load events. Arrays of36* primitive types do not have class load events. Primitive classes (for37* example, java.lang.Integer.TYPE) do not have class load events.</code>38*/39public class classload001 {40static {41try {42System.loadLibrary("classload001");43} catch (UnsatisfiedLinkError ule) {44System.err.println("Could not load \"classload001\" library");45System.err.println("java.library.path:"46+ System.getProperty("java.library.path"));47throw ule;48}49}5051native int check();5253public static void main(String args[]) {54args = nsk.share.jvmti.JVMTITest.commonInit(args);5556// produce JCK-like exit status.57System.exit(run(args, System.out) + Consts.JCK_STATUS_BASE);58}5960public static int run(String args[], PrintStream out) {61return new classload001().runIt(args, out);62}6364private int runIt(String args[], PrintStream out) {65return check();66}6768// classes & arrays used to verify an assertion in the agent69Class boolCls = Boolean.TYPE;70Class byteCls = Byte.TYPE;71Class charCls = Character.TYPE;72Class doubleCls = Double.TYPE;73Class floatCls = Float.TYPE;74Class intCls = Integer.TYPE;75Class longCls = Long.TYPE;76Class shortCls = Short.TYPE;7778Class boolClArr[] = {Boolean.TYPE, Boolean.TYPE};79Class byteClArr[] = {Byte.TYPE, Byte.TYPE};80Class charClArr[] = {Character.TYPE};81Class doubleClArr[] = {Double.TYPE};82Class floatClArr[] = {Float.TYPE, Float.TYPE};83Class intClArr[] = {Integer.TYPE};84Class longClArr[] = {Long.TYPE};85Class shortClArr[] = {Short.TYPE, Short.TYPE};8687boolean boolArr[] = {false, true};88byte byteArr[] = {Byte.MAX_VALUE};89char charArr[] = {'a'};90double doubleArr[] = {Double.MIN_VALUE};91float floatArr[] = {Float.MAX_VALUE};92int intArr[] = {Integer.MIN_VALUE};93long longArr[] = {Long.MAX_VALUE};94short shortArr[] = {Short.MIN_VALUE};9596TestedClass testedCls[] = {new TestedClass()};9798class TestedClass {}99}100101102