author | ihse |
Tue, 20 Feb 2018 21:47:54 +0100 | |
changeset 48923 | b75c9e2e3b1f |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
23175
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
1 |
/* |
43467 | 2 |
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
23175
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
4 |
* |
892220ab2ae1
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 |
892220ab2ae1
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 |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
8 |
* |
892220ab2ae1
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 |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
892220ab2ae1
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 |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
13 |
* accompanied this code). |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
14 |
* |
892220ab2ae1
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 |
892220ab2ae1
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, |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
18 |
* |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
892220ab2ae1
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 |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
21 |
* questions. |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
22 |
*/ |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
23 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
24 |
/* |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
25 |
* @test |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
26 |
* @summary Redefine a class with an UnresolvedClass reference in the constant pool. |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
27 |
* @bug 8035150 |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
28 |
* @library /test/lib |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24835
diff
changeset
|
30 |
* java.compiler |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24835
diff
changeset
|
31 |
* java.instrument |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24835
diff
changeset
|
32 |
* java.management |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24835
diff
changeset
|
33 |
* jdk.jartool/sun.tools.jar |
43467 | 34 |
* jdk.internal.jvmstat/sun.jvmstat.monitor |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
35 |
* @build UnresolvedClassAgent |
23175
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
36 |
* @run main TestRedefineWithUnresolvedClass |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
37 |
*/ |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
38 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
39 |
import java.io.File; |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
40 |
import java.util.Arrays; |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
41 |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
42 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
43 |
import jdk.test.lib.process.ProcessTools; |
23175
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
44 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
45 |
public class TestRedefineWithUnresolvedClass { |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
46 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
47 |
final static String slash = File.separator; |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
48 |
final static String testClasses = System.getProperty("test.classes") + slash; |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
49 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
50 |
public static void main(String... args) throws Throwable { |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
51 |
// delete this class to cause a NoClassDefFoundError |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
52 |
File unresolved = new File(testClasses, "MyUnresolvedClass.class"); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
53 |
if (unresolved.exists() && !unresolved.delete()) { |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
54 |
throw new Exception("Could not delete: " + unresolved); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
55 |
} |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
56 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
57 |
// build the javaagent |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
58 |
buildJar("UnresolvedClassAgent"); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
59 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
60 |
// launch a VM with the javaagent |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
61 |
launchTest(); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
62 |
} |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
63 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
64 |
private static void buildJar(String jarName) throws Throwable { |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
65 |
String testSrc = System.getProperty("test.src", "?") + slash; |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
66 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
67 |
String jarPath = String.format("%s%s.jar", testClasses, jarName); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
68 |
String manifestPath = String.format("%s%s.mf", testSrc, jarName); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
69 |
String className = String.format("%s.class", jarName); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
70 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
71 |
String[] args = new String[] {"-cfm", jarPath, manifestPath, "-C", testClasses, className}; |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
72 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
73 |
System.out.println("Running jar " + Arrays.toString(args)); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
74 |
sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar"); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
75 |
if (!jarTool.run(args)) { |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
76 |
throw new Exception("jar failed: args=" + Arrays.toString(args)); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
77 |
} |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
78 |
} |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
79 |
|
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
80 |
private static void launchTest() throws Throwable { |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
81 |
String[] args = { |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
82 |
"-javaagent:" + testClasses + "UnresolvedClassAgent.jar", |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
83 |
"-Dtest.classes=" + testClasses, |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
84 |
"UnresolvedClassAgent" }; |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
85 |
OutputAnalyzer output = ProcessTools.executeTestJvm(args); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
86 |
output.shouldHaveExitValue(0); |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
87 |
} |
892220ab2ae1
8035150: ShouldNotReachHere() in ConstantPool::copy_entry_to
sla
parents:
diff
changeset
|
88 |
} |