Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk008/TestDescription.java
40955 views
/*1* Copyright (c) 2018, 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/ClassFileLoadHook/classfloadhk008.28* VM Testbase keywords: [quick, jpda, jvmti, noras, redefine]29* VM Testbase readme:30* DESCRIPTION31* This JVMTI test exercises JVMTI event ClassFileLoadHook().32* This test checks if CLASS_FILE_LOAD_HOOK event is received33* for class being redefined and the new instrumented bytecode34* returned from this event callback will be used for tested35* class after redefinition.36* The tested class is loaded with default classloader.37* This test uses three different bytecodes of the tested class38* 'classfloadhk008r' compiled from the different sources.39* This directory contains original source of the tested class,40* which is used to load class with default loader in debuggee class.41* The subdirectory 'newclass' contains redefined class42* with changed implementation of methods.43* The subdirectory 'newclass01' contains new instrumented class44* with one more changed implementation of methods.45* The test performs the following checks:46* - CLASS_FILE_LOAD_HOOK event callback is invoked and only once47* for the tested class upon its redefinition48* - pointers to new redefined bytecode and size passed to49* the event callback are not NULL50* - the new instrumented bytecode is successfully returned51* from the event callback52* - the new instrumented bytecode of the tested class is actually53* used after class redefinition54* The debuggee class preliminary loads redefined and instrumented55* bytecodes of the tested class into static fields and agent gets56* these bytecodes to use them in CLASS_FILE_LOAD_HOOK event callback.57* The debuggee loads tested class using default classloader.58* The agent enables CLASS_FILE_LOAD_HOOK event and redefines59* tested class with the redefined bytecode.60* Upon receiving CLASS_FILE_LOAD_HOOK event the agent performs checks61* and replaces redefined bytecode with the new instrumented bytecode.62* If no CLASS_FILE_LOAD_HOOK events were received, the agent63* complains an error.64* After tested class has been redefined debuggee uses reflection65* API to call static method of this class. If method returns value66* according to the new instrumented implementation, then the new67* bytecode was actually used for creation of tested class. Otherwise,68* if method returns value according to the original or redefined69* implementation, or any unexpected value, then the test complains70* an error.71* The agent does not deallocate memory used for instrumented72* bytecode, because this is VM responsibility.73* If all checks are successfull, the test passes with exit code 95,74* otherwise the test fails with exit code 97.75* COMMENTS76* Modified due to fix of the rfe77* 5010823 TEST_RFE: some JVMTI tests use the replaced capability78*79* @library /vmTestbase80* /test/lib81* @build nsk.jvmti.ClassFileLoadHook.classfloadhk00882* nsk.jvmti.ClassFileLoadHook.classfloadhk008r83*84* @comment compile newclassXX to bin/newclassXX85* @run driver nsk.share.ExtraClassesBuilder86* newclass newclass0187*88* @run main/othervm/native89* -agentlib:classfloadhk008=-waittime=590* nsk.jvmti.ClassFileLoadHook.classfloadhk00891* ./bin92*/93949596