1 /* 2 * Copyright (c) 2018, 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 * @run driver jdk.test.lib.FileInstaller . . 70 * @build nsk.share.Consts 71 * 72 * @comment compile ../bootclssearch003/loadclassXX to bin/loadclassXX 73 * @run driver nsk.share.ExtraClassesBuilder 74 * ../bootclssearch003/loadclass 75 * 76 * @comment compile ../bootclssearch003/newclassXX to bin/newclassXX 77 * @run driver nsk.share.ExtraClassesBuilder 78 * ../bootclssearch003/newclass 79 * 80 * @comment create bootclssearch003.jar in current directory 81 * @build ExecDriver 82 * @run driver PropertyResolvingWrapper ExecDriver --cmd 83 * ${compile.jdk}/bin/jar 84 * -cf bootclssearch003.jar 85 * -C ./bin/newclass/ 86 * nsk/jvmti/AddToBootstrapClassLoaderSearch/bootclssearch003.class 87 * 88 * @run main/othervm/native PropertyResolvingWrapper ExecDriver --java 89 * -Xbootclasspath/a:./bin/loadclass 90 * "-agentlib:bootclssearch_agent=-waittime=5 phasetocheck=live segment1=./bootclssearch003.jar" 91 * nsk.jvmti.AddToBootstrapClassLoaderSearch.bootclssearch003 92 */ 93 94