author | mseledtsov |
Wed, 16 May 2018 16:43:11 -0700 | |
changeset 50154 | d2d6bc39ea88 |
permissions | -rw-r--r-- |
50154
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
1 |
/* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
4 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
8 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
13 |
* accompanied this code). |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
14 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
18 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
21 |
* questions. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
22 |
*/ |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
23 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
24 |
package nsk.sysdict.share; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
25 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
26 |
import java.lang.reflect.Field; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
27 |
import nsk.share.Failure; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
28 |
import nsk.share.TestFailure; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
29 |
import nsk.share.sysdict.ClassLoadersChain; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
30 |
import nsk.share.test.Tests; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
31 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
32 |
/** |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
33 |
* This is a main class for all chain tests. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
34 |
*/ |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
35 |
public class ChainTest extends SysDictTest { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
36 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
37 |
public ChainTest(String[] args) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
38 |
parseArgs(args); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
39 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
40 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
41 |
public static void main(String args[]) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
42 |
Tests.runTest(new ChainTest(args), args); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
43 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
44 |
private static final int NxM_FACTOR = 450; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
45 |
private int classesHeight; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
46 |
private int loadersHeight; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
47 |
String[] classNames; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
48 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
49 |
@Override |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
50 |
protected void parseArgs(String args[]) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
51 |
super.parseArgs(args); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
52 |
boolean isLoaderHeightDefault = true; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
53 |
boolean isHeightDefault = true; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
54 |
for (int i = 0; i < args.length; i++) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
55 |
if (args[i].equals("-classloaderHeight")) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
56 |
loadersHeight = Integer.parseInt(args[i + 1]); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
57 |
if (loadersHeight > 0) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
58 |
isLoaderHeightDefault = false; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
59 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
60 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
61 |
if (args[i].equals("-height")) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
62 |
classesHeight = Integer.parseInt(args[i + 1]); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
63 |
if (classesHeight > 0) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
64 |
isHeightDefault = false; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
65 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
66 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
67 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
68 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
69 |
Class info; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
70 |
try { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
71 |
if (useFats) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
72 |
info = createJarLoader().loadClass(PACKAGE_PREFIX + "FatsInfo"); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
73 |
} else { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
74 |
info = createJarLoader().loadClass(PACKAGE_PREFIX + "LeansInfo"); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
75 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
76 |
System.out.println("name=" + info.getName()); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
77 |
for (Field field : info.getDeclaredFields()) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
78 |
System.err.println("field = " + field.getName()); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
79 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
80 |
if (isHeightDefault) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
81 |
classesHeight = info.getField("HEIGHT").getInt(null); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
82 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
83 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
84 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
85 |
if (isLoaderHeightDefault) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
86 |
loadersHeight = NxM_FACTOR / classesHeight; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
87 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
88 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
89 |
if (loadersHeight * classesHeight != NxM_FACTOR) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
90 |
throw new Failure("classes height must divide " + NxM_FACTOR); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
91 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
92 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
93 |
if (loadersHeight == 0) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
94 |
throw new Failure("loaders height should be positive"); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
95 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
96 |
if (classesHeight == 0) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
97 |
throw new Failure("classes height should be positive"); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
98 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
99 |
classNames = new String[classesHeight]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
100 |
for (int i = 0; i < classesHeight; i++) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
101 |
classNames[i] = PACKAGE_PREFIX + info.getField("rootName").get(null) |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
102 |
+ ((String[]) info.getField("nodeNames").get(null))[i]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
103 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
104 |
if (classNames == null || classNames.length == 0) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
105 |
throw new TestFailure("No classes names for loading"); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
106 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
107 |
System.out.println("The classHeight = " + classesHeight + " the loadersHeight = " + loadersHeight); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
108 |
} catch (Exception e) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
109 |
throw new TestFailure("Can't initialize test correctly", e); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
110 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
111 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
112 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
113 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
114 |
@Override |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
115 |
String[] getClassNames() { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
116 |
return classNames; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
117 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
118 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
119 |
@Override |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
120 |
ClassLoader[] createLoaders() { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
121 |
ClassLoader loaders[] = new ClassLoader[loadersHeight]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
122 |
ClassLoader jarLoader = createJarLoader(); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
123 |
ClassLoadersChain loadersChain = |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
124 |
new ClassLoadersChain(jarLoader, loadersHeight); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
125 |
// direct ordering: root loader first |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
126 |
for (int i = 0; i < loadersHeight; i++) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
127 |
loaders[i] = loadersChain.getLoader(loadersHeight - 1 - i); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
128 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
129 |
return loaders; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
130 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
131 |
} |