test/serviceability/jvmti/TestRedefineWithUnresolvedClass.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 6717
09f19d3de485
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

sla@6338 1 /*
sla@6338 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
sla@6338 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sla@6338 4 *
sla@6338 5 * This code is free software; you can redistribute it and/or modify it
sla@6338 6 * under the terms of the GNU General Public License version 2 only, as
sla@6338 7 * published by the Free Software Foundation.
sla@6338 8 *
sla@6338 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sla@6338 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sla@6338 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sla@6338 12 * version 2 for more details (a copy is included in the LICENSE file that
sla@6338 13 * accompanied this code).
sla@6338 14 *
sla@6338 15 * You should have received a copy of the GNU General Public License version
sla@6338 16 * 2 along with this work; if not, write to the Free Software Foundation,
sla@6338 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sla@6338 18 *
sla@6338 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sla@6338 20 * or visit www.oracle.com if you need additional information or have any
sla@6338 21 * questions.
sla@6338 22 */
sla@6338 23
sla@6338 24 /*
sla@6338 25 * @test
sla@6338 26 * @summary Redefine a class with an UnresolvedClass reference in the constant pool.
sla@6338 27 * @bug 8035150
sla@6338 28 * @library /testlibrary
ykantser@6717 29 * @build com.oracle.java.testlibrary.* UnresolvedClassAgent
sla@6338 30 * @run main TestRedefineWithUnresolvedClass
sla@6338 31 */
sla@6338 32
sla@6338 33 import java.io.File;
sla@6338 34 import java.util.Arrays;
sla@6338 35
sla@6338 36 import com.oracle.java.testlibrary.OutputAnalyzer;
sla@6338 37 import com.oracle.java.testlibrary.ProcessTools;
sla@6338 38
sla@6338 39 public class TestRedefineWithUnresolvedClass {
sla@6338 40
sla@6338 41 final static String slash = File.separator;
sla@6338 42 final static String testClasses = System.getProperty("test.classes") + slash;
sla@6338 43
sla@6338 44 public static void main(String... args) throws Throwable {
sla@6338 45 // delete this class to cause a NoClassDefFoundError
sla@6338 46 File unresolved = new File(testClasses, "MyUnresolvedClass.class");
sla@6338 47 if (unresolved.exists() && !unresolved.delete()) {
sla@6338 48 throw new Exception("Could not delete: " + unresolved);
sla@6338 49 }
sla@6338 50
sla@6338 51 // build the javaagent
sla@6338 52 buildJar("UnresolvedClassAgent");
sla@6338 53
sla@6338 54 // launch a VM with the javaagent
sla@6338 55 launchTest();
sla@6338 56 }
sla@6338 57
sla@6338 58 private static void buildJar(String jarName) throws Throwable {
sla@6338 59 String testSrc = System.getProperty("test.src", "?") + slash;
sla@6338 60
sla@6338 61 String jarPath = String.format("%s%s.jar", testClasses, jarName);
sla@6338 62 String manifestPath = String.format("%s%s.mf", testSrc, jarName);
sla@6338 63 String className = String.format("%s.class", jarName);
sla@6338 64
sla@6338 65 String[] args = new String[] {"-cfm", jarPath, manifestPath, "-C", testClasses, className};
sla@6338 66
sla@6338 67 System.out.println("Running jar " + Arrays.toString(args));
sla@6338 68 sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
sla@6338 69 if (!jarTool.run(args)) {
sla@6338 70 throw new Exception("jar failed: args=" + Arrays.toString(args));
sla@6338 71 }
sla@6338 72 }
sla@6338 73
sla@6338 74 private static void launchTest() throws Throwable {
sla@6338 75 String[] args = {
sla@6338 76 "-javaagent:" + testClasses + "UnresolvedClassAgent.jar",
sla@6338 77 "-Dtest.classes=" + testClasses,
sla@6338 78 "UnresolvedClassAgent" };
sla@6338 79 OutputAnalyzer output = ProcessTools.executeTestJvm(args);
sla@6338 80 output.shouldHaveExitValue(0);
sla@6338 81 }
sla@6338 82 }

mercurial