annotate test/serviceability/jvmti/TestRedefineWithUnresolvedClass.java @ 19299:8e4f683e16d9

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