Mercurial > hg > truffle
annotate test/compiler/jsr292/ConcurrentClassLoadingTest.java @ 18049:f3c3ce3fb624
8038898: Safer safepoints
Reviewed-by: kvn, ahgross
author | twisti |
---|---|
date | Mon, 21 Apr 2014 10:36:31 -1000 |
parents | 68ec0a75ee22 |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
12163
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
1 /* |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
4 * |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
8 * |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
13 * accompanied this code). |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
14 * |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
18 * |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
21 * questions. |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
22 */ |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
23 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
24 /** |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
25 * @test |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
26 * @bug 8022595 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
27 * @summary JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
28 * |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
29 * @run main/othervm ConcurrentClassLoadingTest |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
30 */ |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
31 import java.util.*; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
32 import java.util.concurrent.BrokenBarrierException; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
33 import java.util.concurrent.CyclicBarrier; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
34 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
35 public class ConcurrentClassLoadingTest { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
36 int numThreads = 0; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
37 long seed = 0; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
38 CyclicBarrier l; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
39 Random rand; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
40 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
41 public static void main(String[] args) throws Throwable { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
42 ConcurrentClassLoadingTest test = new ConcurrentClassLoadingTest(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
43 test.parseArgs(args); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
44 test.run(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
45 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
46 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
47 void parseArgs(String[] args) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
48 int i = 0; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
49 while (i < args.length) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
50 String flag = args[i]; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
51 switch(flag) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
52 case "-seed": |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
53 seed = Long.parseLong(args[++i]); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
54 break; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
55 case "-numThreads": |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
56 numThreads = Integer.parseInt(args[++i]); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
57 break; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
58 default: |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
59 throw new Error("Unknown flag: " + flag); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
60 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
61 ++i; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
62 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
63 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
64 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
65 void init() { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
66 if (numThreads == 0) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
67 numThreads = Runtime.getRuntime().availableProcessors(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
68 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
69 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
70 if (seed == 0) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
71 seed = (new Random()).nextLong(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
72 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
73 rand = new Random(seed); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
74 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
75 l = new CyclicBarrier(numThreads + 1); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
76 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
77 System.out.printf("Threads: %d\n", numThreads); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
78 System.out.printf("Seed: %d\n", seed); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
79 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
80 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
81 final List<Loader> loaders = new ArrayList<>(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
82 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
83 void prepare() { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
84 List<String> c = new ArrayList<>(Arrays.asList(classNames)); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
85 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
86 // Split classes between loading threads |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
87 int count = (classNames.length / numThreads) + 1; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
88 for (int t = 0; t < numThreads; t++) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
89 List<String> sel = new ArrayList<>(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
90 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
91 System.out.printf("Thread #%d:\n", t); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
92 for (int i = 0; i < count; i++) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
93 if (c.size() == 0) break; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
94 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
95 int k = rand.nextInt(c.size()); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
96 String elem = c.remove(k); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
97 sel.add(elem); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
98 System.out.printf("\t%s\n", elem); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
99 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
100 loaders.add(new Loader(sel)); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
101 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
102 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
103 // Print diagnostic info when the test hangs |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
104 Runtime.getRuntime().addShutdownHook(new Thread() { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
105 public void run() { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
106 boolean alive = false; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
107 for (Loader l : loaders) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
108 if (!l.isAlive()) continue; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
109 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
110 if (!alive) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
111 System.out.println("Some threads are still alive:"); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
112 alive = true; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
113 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
114 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
115 System.out.println(l.getName()); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
116 for (StackTraceElement elem : l.getStackTrace()) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
117 System.out.println("\t"+elem.toString()); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
118 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
119 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
120 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
121 }); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
122 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
123 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
124 public void run() throws Throwable { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
125 init(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
126 prepare(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
127 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
128 for (Loader loader : loaders) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
129 loader.start(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
130 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
131 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
132 l.await(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
133 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
134 for (Loader loader : loaders) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
135 loader.join(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
136 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
137 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
138 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
139 class Loader extends Thread { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
140 List<String> classes; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
141 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
142 public Loader(List<String> classes) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
143 this.classes = classes; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
144 setDaemon(true); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
145 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
146 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
147 @Override |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
148 public void run() { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
149 try { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
150 l.await(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
151 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
152 for (String name : classes) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
153 Class.forName(name).getName(); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
154 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
155 } catch (ClassNotFoundException | BrokenBarrierException | InterruptedException e) { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
156 throw new Error(e); |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
157 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
158 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
159 } |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
160 |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
161 final static String[] classNames = { |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
162 "java.lang.invoke.CallSite", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
163 "java.lang.invoke.ConstantCallSite", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
164 "java.lang.invoke.LambdaConversionException", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
165 "java.lang.invoke.LambdaMetafactory", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
166 "java.lang.invoke.MethodHandle", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
167 "java.lang.invoke.MethodHandleInfo", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
168 "java.lang.invoke.MethodHandleProxies", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
169 "java.lang.invoke.MethodHandles", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
170 "java.lang.invoke.MethodType", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
171 "java.lang.invoke.MutableCallSite", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
172 "java.lang.invoke.SerializedLambda", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
173 "java.lang.invoke.SwitchPoint", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
174 "java.lang.invoke.VolatileCallSite", |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
175 "java.lang.invoke.WrongMethodTypeException" |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
176 }; |
74608df95ba3
8022595: JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
vlivanov
parents:
diff
changeset
|
177 } |