Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk007/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/classfloadhk007.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* upon redefinition of tested class correct class and classloader34* references as well as redefined bytecode are passed to35* the event callback.36* The tested class is loaded with custom classloader,37* This test uses two different bytecodes of the tested class38* 'classfloadhk007r' compiled from the different sources.39* The subdirectory 'loadclass' contains original source of40* the tested class, which is used to load class with custom41* classloader in debuggee class.42* The subdirectory 'newclass' contains redefined class43* with changed implementation of methods.44* The test performs the following checks:45* - CLASS_FILE_LOAD_HOOK event callback is invoked and only once46* for the tested class upon its redefinition47* - reference to redefined class passed to the event callback48* is equal to expected one49* - reference to classloader passed to the event callback50* is equal to expected one51* - redefined bytecode passed to the event callback is equal52* to expected one53* - the new redefined bytecode of the tested class is actually54* used after class redefinition55* The debuggee class preliminary loads redefined bytecode of56* the tested class into static field and agent gets this57* bytecode to use it in CLASS_FILE_LOAD_HOOK event callback.58* The debuggee loads tested class using custom classloader.59* The agent enables CLASS_FILE_LOAD_HOOK event and redefines60* tested class with the new bytecode.61* Upon receiving CLASS_FILE_LOAD_HOOK event the agent performs62* checks for class reference, classloader and bytecode passed63* to the event callback.64* If no CLASS_FILE_LOAD_HOOK events were received, the agent65* complains an error.66* After tested class has been redefined debuggee uses reflection67* API to call static method of this class. If method returns value68* according to the redefined implementation, then the new bytecode69* was actually used for redefinition of tested class. Otherwise,70* if method returns value according to the old implementation,71* or any unexpected value, then the test complains an error.72* If all checks are successfull, the test passes with exit code 95,73* otherwise the test fails with exit code 97.74* COMMENTS75* Modified due to fix of the rfe76* 5010823 TEST_RFE: some JVMTI tests use the replaced capability77*78* @library /vmTestbase79* /test/lib80* @build nsk.jvmti.ClassFileLoadHook.classfloadhk00781*82* @comment compile loadclassXX to bin/loadclassXX83* @run driver nsk.share.ExtraClassesBuilder84* loadclass85*86* @comment compile newclassXX to bin/newclassXX87* @run driver nsk.share.ExtraClassesBuilder88* newclass89*90* @run main/othervm/native91* -agentlib:classfloadhk007=-waittime=592* nsk.jvmti.ClassFileLoadHook.classfloadhk00793* ./bin94*/95969798