Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch002/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/bootclssearch002.28* VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, no_cds]29* VM Testbase readme:30* DESCRIPTION31* This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch().32* This test checks that AddToBootstrapClassLoaderSearch() adds segment33* to bootstrap class search path and bootstrap classloader will find34* debuggee class using that segment.35* Debuggee class has direct superclass located in the original bootstrap classpath.36* The following checks are performed by the test:37* - AddToBootstrapClassLoaderSearch() returns no errors in OnLoad phase38* - debuggee class will be found by bootstrap classloader using added segment39* - superclass needed for debuggee class will be also found by bootstrap40* classloader though located in the original bootstrap classpath41* - superclass needed for debuggee class will be loaded from bootstrap42* classpath, not from usual classpath43* Source of debuggee class 'bootclssearch002' is located in subdirectory 'newclass'.44* It will be compiled to '$COMMON_CLASSES_LOCATION/newclass', where it usually45* cannot be found by bootstrap classloader.46* The superclass 'bootclssearch002p' has two different implementations.47* Source of "positive" implementation is located in subdirectory 'loadclass'.48* It will be compiled to '$COMMON_CLASSES_LOCATION/loadclass' that is added49* to original bootstrap classpath using option -Xbootclasspath/a.50* This implementation returns PASS.51* Source of "negative" implementation is located in the currect directory.52* It will be compiled to '$COMMON_CLASSES_LOCATION/classes' that is available53* from usual classpath.54* This implementation prints error and returns FAIL.55* The agent adds '$COMMON_CLASSES_LOCATION/newclass' directory with debuggee56* class implementation to the bootstrap class search path in Agent_OnLoad(),57* and thus the debuggee class should be found by bootstrap classloader.58* While loading debuggee class the bootstrap classloader should find and load59* "positive" implementation of superclass available from original bootstrap60* classpath, but not "negative" implementation available from usual classpath.61* If AddToBootstrapClassLoaderSearch() returns error in Agent_OnLoad(),62* then agent returns JNI_ERR and VM fails on initialization.63* If AddToBootstrapClassLoaderSearch() does not adds segment to bootstrap64* classloader search path, then debuggee class is not found and VM65* fails on initialization.66* If bootstrap classloader cannot find superclass located by the original67* bootstrap classpath, then VM also fails on initialization.68* If bootstrap classloader loads "negative" implementation of superclass69* available from usual classpath, then the debuggee class returns FAIL,70* and the test fails with exit code 97.71* Otherwise, if segment is successfully added and debuggee class with positive72* implementation of superclass are found, loaded, and executed, then it73* returns PASS. and the test passes with exit code 95.74* COMMENTS75* Made code cleanup: nsk/share/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch_agent76* agent is used now.77*78* @library /vmTestbase79* /test/lib80* @build nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch002p81*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* @comment ExecDriver is used b/c main class isn't on source/class path91* @run main/othervm/native ExecDriver --java92* -Xbootclasspath/a:./bin/loadclass93* -agentlib:bootclssearch_agent=-waittime=5,phasetocheck=onload,segment1=./bin/newclass94* nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch00295*/96979899