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/AttachOnDemand/attach002a. 29 * VM Testbase keywords: [quick, jpda, jvmti, noras, redefine, feature_282, vm6, jdk] 30 * VM Testbase readme: 31 * Description : 32 * Test tries to load jvmti agent to the VM after the VM has started using 33 * Attach API (com.sun.tools.attach). 34 * Test is based on the nsk.share.aod framework. In the terms of this framework 35 * java application running in the VM where agent is loaded to is called 'target application'. 36 * This is regression test for "5002268: Allow class sharing use with RedefineClasses". 37 * Test tries to redefine class java.lang.InterruptedException (class from the system jar which 38 * is included in the shared archive). 39 * (5002268 was fixed in JDK6 b86, with earlier builds this test fails because of JVMTI function 40 * RedefineClasses fails with error JVMTI_ERROR_UNMODIFIABLE_CLASS). 41 * Test scenario: 42 * - during initialization agent tries to get capabilities 'can_generate_vm_object_alloc_events' 43 * and 'can_redefine_classes' and enables VMObjectAlloc events 44 * - target application creates instance of InterruptedException using InterruptedException.class.newInstance, 45 * after this agent should receive VMObjectAlloc event 46 * - agent receives VMObjectAlloc event, redefines InterruptedException class and finishes work 47 * - target application creates one more instance of Interrupted exception and checks that redefinition 48 * really had effect 49 * 50 * @library /vmTestbase 51 * /test/lib 52 * @build nsk.share.aod.AODTestRunner 53 * 54 * @comment compile newclassXX to bin/newclassXX 55 * @run driver ExecDriver --cmd 56 * ${compile.jdk}/bin/javac 57 * --patch-module java.base=${test.src}/newclass00/java.base 58 * -d bin/newclass00 59 * ${test.src}/newclass00/java.base/java/lang/InterruptedException.java 60 * 61 * @build nsk.jvmti.AttachOnDemand.attach002a.attach002aTarget 62 * @run main/othervm/native 63 * nsk.share.aod.AODTestRunner 64 * -jdk ${test.jdk} 65 * -target nsk.jvmti.AttachOnDemand.attach002a.attach002aTarget 66 * -javaOpts="-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}" 67 * -na attach002aAgent00=-pathToNewByteCode=./bin/newclass00 68 */ 69 70