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/scenarios/bcinstr/BI04/bi04t002. 29 * VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras, redefine, no_cds] 30 * VM Testbase readme: 31 * DESCRIPTION 32 * This JVMTI test is developed against "bytecode instrumentation" area. 33 * The test performs the following actions: 34 * - instrument all java methods of java.lang.Object via RedefineClasses 35 * function; 36 * - check that instrumentation code works. 37 * There are some notes regarding new bytecode for java.lang.Object class: 38 * - new bytecode for java.lang.Object class is precompiled and its 39 * classfile is placed in $COMMON_CLASSES_LOCATION/newclass02 directory; 40 * - source of new bytecode for java.lang.Object is the modified original 41 * source file borrowed from JDK 1.5.0-beta2-b43, thus it should be 42 * compiled with the '-source 1.5' option; 43 * - every java-method of instrumeneted java.lang.Object class invokes 44 * a method of test which carries out special action in order to register 45 * invocation, so $COMMON_CLASSES_LOCATION/classes must be added to the 46 * default bootstrap class path; 47 * These points could be considered as a negative side of this tests. 48 * As alternative way - java.lang.Object could be instrumented by bytecode 49 * generated _on_the_fly_. But such implementation would complicate test. 50 * COMMENTS 51 * 52 * @library /vmTestbase 53 * /test/lib 54 * @build nsk.jvmti.scenarios.bcinstr.BI04.bi04t002 55 * nsk.jvmti.scenarios.bcinstr.BI04.bi04t002a 56 * 57 * @comment compile newclassXX to bin/newclassXX 58 * @run driver ExecDriver --cmd 59 * ${compile.jdk}/bin/javac 60 * --patch-module java.base=${test.src}/newclass02/java.base 61 * -d bin/newclass02 62 * -cp ${test.class.path} 63 * --add-reads=java.base=ALL-UNNAMED 64 * ${test.src}/newclass02/java.base/java/lang/Object.java 65 * 66 * @run main/othervm/native 67 * --add-reads=java.base=ALL-UNNAMED 68 * -XX:+UnlockDiagnosticVMOptions 69 * -XX:-CheckIntrinsics 70 * -Xbootclasspath/a:${test.class.path} 71 * -agentlib:bi04t002=pathToNewByteCode=./bin,-waittime=5 72 * nsk.jvmti.scenarios.bcinstr.BI04.bi04t002 73 */ 74