Mercurial > hg > truffle
annotate test/gc/metaspace/G1AddMetaspaceDependency.java @ 18546:17b5e453ab41
replaced concrete types with interface types to support replay compilation
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 26 Nov 2014 20:50:49 +0100 |
parents | 77a774ab3cf0 |
children |
rev | line source |
---|---|
9075
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
1 /* |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
4 * |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
8 * |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
13 * accompanied this code). |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
14 * |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
18 * |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
21 * questions. |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
22 */ |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
23 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
24 /* |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
25 * @test G1AddMetaspaceDependency |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
26 * @bug 8010196 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
27 * @summary Checks that we don't get locking problems when adding metaspace dependencies with the G1 update buffer monitor |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
28 * @run main/othervm -XX:+UseG1GC -XX:G1UpdateBufferSize=1 G1AddMetaspaceDependency |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
29 */ |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
30 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
31 import java.io.InputStream; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
32 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
33 public class G1AddMetaspaceDependency { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
34 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
35 static byte[] getClassBytes(String name) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
36 byte[] b = null; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
37 try (InputStream is = ClassLoader.getSystemResourceAsStream(name)) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
38 byte[] tmp = new byte[is.available()]; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
39 is.read(tmp); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
40 b = tmp; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
41 } finally { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
42 if (b == null) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
43 throw new RuntimeException("Unable to load class file"); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
44 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
45 return b; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
46 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
47 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
48 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
49 static final String a_name = G1AddMetaspaceDependency.class.getName() + "$A"; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
50 static final String b_name = G1AddMetaspaceDependency.class.getName() + "$B"; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
51 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
52 public static void main(String... args) throws Exception { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
53 final byte[] a_bytes = getClassBytes(a_name + ".class"); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
54 final byte[] b_bytes = getClassBytes(b_name + ".class"); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
55 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
56 for (int i = 0; i < 1000; i += 1) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
57 runTest(a_bytes, b_bytes); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
58 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
59 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
60 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
61 static class Loader extends ClassLoader { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
62 private final String myClass; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
63 private final byte[] myBytes; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
64 private final String friendClass; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
65 private final ClassLoader friendLoader; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
66 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
67 Loader(String myClass, byte[] myBytes, |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
68 String friendClass, ClassLoader friendLoader) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
69 this.myClass = myClass; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
70 this.myBytes = myBytes; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
71 this.friendClass = friendClass; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
72 this.friendLoader = friendLoader; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
73 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
74 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
75 Loader(String myClass, byte[] myBytes) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
76 this(myClass, myBytes, null, null); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
77 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
78 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
79 @Override |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
80 public Class<?> loadClass(String name) throws ClassNotFoundException { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
81 Class<?> c = findLoadedClass(name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
82 if (c != null) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
83 return c; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
84 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
85 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
86 if (name.equals(friendClass)) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
87 return friendLoader.loadClass(name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
88 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
89 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
90 if (name.equals(myClass)) { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
91 c = defineClass(name, myBytes, 0, myBytes.length); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
92 resolveClass(c); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
93 return c; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
94 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
95 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
96 return findSystemClass(name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
97 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
98 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
99 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
100 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
101 private static void runTest(final byte[] a_bytes, final byte[] b_bytes) throws Exception { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
102 Loader a_loader = new Loader(a_name, a_bytes); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
103 Loader b_loader = new Loader(b_name, b_bytes, a_name, a_loader); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
104 Loader c_loader = new Loader(b_name, b_bytes, a_name, a_loader); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
105 Loader d_loader = new Loader(b_name, b_bytes, a_name, a_loader); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
106 Loader e_loader = new Loader(b_name, b_bytes, a_name, a_loader); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
107 Loader f_loader = new Loader(b_name, b_bytes, a_name, a_loader); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
108 Loader g_loader = new Loader(b_name, b_bytes, a_name, a_loader); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
109 |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
110 Class<?> c; |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
111 c = b_loader.loadClass(b_name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
112 c = c_loader.loadClass(b_name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
113 c = d_loader.loadClass(b_name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
114 c = e_loader.loadClass(b_name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
115 c = f_loader.loadClass(b_name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
116 c = g_loader.loadClass(b_name); |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
117 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
118 public class A { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
119 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
120 class B extends A { |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
121 } |
ba42fd5e00e6
8010196: NPG: Internal Error: Metaspace allocation lock -- possible deadlock
mgerdin
parents:
diff
changeset
|
122 } |