author | chegar |
Tue, 09 Aug 2011 16:39:04 +0100 | |
changeset 10150 | dee4cb73adc3 |
parent 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
272
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
272
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
4 |
* |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
8 |
* |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
13 |
* accompanied this code). |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
14 |
* |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
272
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
22 |
*/ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
23 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
24 |
/** |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
25 |
* Test Java Program |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
26 |
* |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
27 |
* @author Daryl Puryear |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
28 |
* @copyright 1999-2004 Wily Technology, Inc. All rights reserved. |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
29 |
*/ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
30 |
public class ParallelTransformerLoaderApp |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
31 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
32 |
private static final int kNumIterations = 1000; |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
33 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
34 |
public static void |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
35 |
main( String[] args) |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
36 |
throws Exception |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
37 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
38 |
System.out.println(); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
39 |
System.out.print("Starting test with " + kNumIterations + " iterations"); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
40 |
for (int i = 0; i < kNumIterations; i++) |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
41 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
42 |
// load some classes from multiple threads (this thread and one other) |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
43 |
Thread testThread = new TestThread(2); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
44 |
testThread.start(); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
45 |
loadClasses(1); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
46 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
47 |
// log that it completed and reset for the next iteration |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
48 |
testThread.join(); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
49 |
System.out.print("."); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
50 |
ParallelTransformerLoaderAgent.generateNewClassLoader(); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
51 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
52 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
53 |
System.out.println(); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
54 |
System.out.println("Test completed successfully"); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
55 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
56 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
57 |
private static class TestThread |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
58 |
extends Thread |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
59 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
60 |
private final int fIndex; |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
61 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
62 |
public |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
63 |
TestThread( int index) |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
64 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
65 |
super("TestThread"); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
66 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
67 |
fIndex = index; |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
68 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
69 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
70 |
public void |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
71 |
run() |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
72 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
73 |
loadClasses(fIndex); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
74 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
75 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
76 |
|
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
77 |
public static void |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
78 |
loadClasses( int index) |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
79 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
80 |
ClassLoader loader = ParallelTransformerLoaderAgent.getClassLoader(); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
81 |
try |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
82 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
83 |
Class.forName("TestClass" + index, true, loader); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
84 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
85 |
catch (Exception e) |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
86 |
{ |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
87 |
e.printStackTrace(); |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
88 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
89 |
} |
c4e0a3afe6f2
5088398: 3/2 java.lang.instrument TCK test deadlock (test11)
dcubed
parents:
diff
changeset
|
90 |
} |