Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch010/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/AddToBootstrapClassLoaderSearch/bootclssearch010.28* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6, no_cds]29* VM Testbase readme:30* DESCRIPTION31* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch()32* in Live phase.33* This test checks that AddToBootstrapClassLoaderSearch() adds segment34* to bootstrap class search path and bootstrap classloader will find35* debuggee class using that segment.36* Debuggee class has direct superclass located in the original bootstrap classpath.37* The following checks are performed by the test:38* - AddToBootstrapClassLoaderSearch() returns no errors in Live phase39* - in particular it checks that anything other than an40* existing JAR file is an invalid path41* - debuggee class will be found by bootstrap classloader using added segment42* - superclass needed for debuggee class will be also found by bootstrap43* classloader though located in the original bootstrap classpath44* - superclass needed for debuggee class will be loaded from bootstrap45* classpath, not from usual classpath46* Source of debuggee class 'bootclssearch002' is located in 'bootclssearch002.jar'47* which is located in subdirectory 'newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/'.48* It will be compiled to49* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002.jar'50* jar file where it usually cannot be found by bootstrap classloader.51* The superclass 'bootclssearch002p' has two different implementations.52* Source of "positive" implementation is located in subdirectory 'loadclass'.53* It will be compiled to '$COMMON_CLASSES_LOCATION/loadclass' that is added54* to original bootstrap classpath using option -Xbootclasspath/a.55* This implementation returns PASS.56* Source of "negative" implementation is located in the currect directory.57* It will be compiled to '$COMMON_CLASSES_LOCATION/classes' that is available58* from usual classpath.59* This implementation prints error and returns FAIL.60* The agent adds61* '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002.jar'62* jar file with debuggee63* class implementation to the bootstrap class search path in VM_INIT callback,64* and thus the debuggee class should be found by bootstrap classloader.65* While loading debuggee class the bootstrap classloader should find and load66* "positive" implementation of superclass available from original bootstrap67* classpath, but not "negative" implementation available from usual classpath.68* If AddToBootstrapClassLoaderSearch() does not adds segment to bootstrap69* classloader search path, then debuggee class is not found and VM70* fails on initialization.71* If bootstrap classloader cannot find superclass located by the original72* bootstrap classpath, then VM also fails on initialization.73* If bootstrap classloader loads "negative" implementation of superclass74* available from usual classpath, then the debuggee class returns FAIL,75* and the test fails with exit code 97.76* Otherwise, if segment is successfully added and debuggee class with positive77* implementation of superclass are found, loaded, and executed, then it78* returns PASS. and the test passes with exit code 95.79* COMMENTS80* Ported from bootclssearch002.81*82* @library /vmTestbase83* /test/lib84* @build nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch002p85*86* @comment compile ../bootclssearch002/loadclassXX to bin/loadclassXX87* @run driver nsk.share.ExtraClassesBuilder88* ../bootclssearch002/loadclass89*90* @comment compile ../bootclssearch002/newclassXX to bin/newclassXX91* @run driver nsk.share.ExtraClassesBuilder92* ../bootclssearch002/newclass93*94* @comment create bootclssearch002.jar in current directory95* @run driver ExecDriver --cmd96* ${compile.jdk}/bin/jar97* -cf bootclssearch002.jar98* -C ./bin/newclass/99* nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002.class100*101* @comment ExecDriver is used b/c main class isn't on source/class path102* @run main/othervm/native ExecDriver --java103* -Xbootclasspath/a:./bin/loadclass104* -agentlib:bootclssearch_agent=-waittime=5,phasetocheck=live,segment1=./bootclssearch002.jar105* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch002106*/107108109110