Path: blob/master/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineObject.java
41153 views
/*1* Copyright (c) 2013, 2021, 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*/22import java.io.PrintWriter;2324import jdk.test.lib.JDKToolFinder;25import jdk.test.lib.process.ProcessTools;26import jdk.test.lib.process.OutputAnalyzer;2728/*29* Test to redefine java/lang/Object and verify that it doesn't crash on vtable30* call on basic array type.31* Test to redefine java/lang/ClassLoader and java/lang/reflect/Method to make32* sure cached versions used afterward are the current version.33*34* @test35* @bug 8005056 8009728 821839936* @requires vm.jvmti37* @requires !vm.graal.enabled38* @library /test/lib39* @modules java.base/jdk.internal.misc40* java.instrument41* java.management42* @build Agent43* @run driver jdk.test.lib.helpers.ClassFileInstaller Agent44* @run driver TestRedefineObject45* @run main/othervm -javaagent:agent.jar -Xlog:redefine+class+load=debug,redefine+class+timer=info Agent46*/47public class TestRedefineObject {48public static void main(String[] args) throws Exception {4950PrintWriter pw = new PrintWriter("MANIFEST.MF");51pw.println("Premain-Class: Agent");52pw.println("Can-Retransform-Classes: true");53pw.close();5455ProcessBuilder pb = new ProcessBuilder();56pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "Agent.class"});57pb.start().waitFor();58}59}606162