1 /* 2 * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 /* 26 * @test 27 * 28 * @summary converted from VM Testbase nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch007. 29 * VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, vm6, no_cds] 30 * VM Testbase readme: 31 * DESCRIPTION 32 * This JVMTI test exercises JVMTI thread function AddToBootstrapClassLoaderSearch() 33 * in Live phase. 34 * This test checks that AddToBootstrapClassLoaderSearch() adds segment 35 * to bootstrap class search path in Live phase, but debuggee class 36 * located by this segment will no be loaded if this class is available 37 * from the original bootstrap classpath. 38 * The following checks are performed by the test: 39 * - AddToBootstrapClassLoaderSearch() returns no errors in Live phase 40 * - in particular it checks that anything other than an 41 * existing JAR file is an invalid path 42 * - debuggee class located by the original bootstrap classpath will be loaded 43 * - debuggee class located by the added segment will NOT be loaded 44 * There are two different impelmentations of debuggee class 'bootclssearch003'. 45 * Source of "positive" implementation is located in subdirectory 'loadclass'. 46 * It will be compiled to '$COMMON_CLASSES_LOCATION/loadclass' and added to 47 * original bootstrap classpath using option -Xbootclasspath/a. 48 * This implementation returns PASS status. 49 * Source of "negative" implementation is located in 'bootclssearch003.jar' 50 * which is located in subdirectory 'newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/'. 51 * It will be compiled to 52 * '$COMMON_CLASSES_LOCATION/newclass/nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.jar' 53 * and added to bootstrap class search path with AddToBootstrapClassLoaderSearch(). 54 * This implementation returns prints error and returns FAIL status. 55 * The agent adds jar file 56 * '$COMMON_CLASSES_LOCATION/newclassnsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.jar' 57 * to the bootstrap classloader search path in VM_INIT callback, and expects 58 * that positive implementation of debuggee class will be loaded and 59 * executed. 60 * If negative version of debuggee class will be loaded and executed, 61 * then it returns FAIL and test fails with exit code 97. 62 * Otherwise, if positive version of debuggee class will be loaded and executed, 63 * then it returns PASS and test passes with exit code 95. 64 * COMMENTS 65 * Ported from bootclssearch003. 66 * 67 * @library /vmTestbase 68 * /test/lib 69 * @build nsk.share.Consts 70 * 71 * @comment compile ../bootclssearch003/loadclassXX to bin/loadclassXX 72 * @run driver nsk.share.ExtraClassesBuilder 73 * ../bootclssearch003/loadclass 74 * 75 * @comment compile ../bootclssearch003/newclassXX to bin/newclassXX 76 * @run driver nsk.share.ExtraClassesBuilder 77 * ../bootclssearch003/newclass 78 * 79 * @comment create bootclssearch003.jar in current directory 80 * @run driver ExecDriver --cmd 81 * ${compile.jdk}/bin/jar 82 * -cf bootclssearch003.jar 83 * -C ./bin/newclass/ 84 * nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.class 85 * 86 * @comment ExecDriver is used b/c main class isn't on source/class path 87 * @run main/othervm/native ExecDriver --java 88 * -Xbootclasspath/a:./bin/loadclass 89 * -agentlib:bootclssearch_agent=-waittime=5,phasetocheck=live,segment1=./bootclssearch003.jar 90 * nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch003 91 */ 92 93