48138
|
1 |
/*
|
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
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.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
* @test
|
|
27 |
* @summary Ensure that classes found in jimage takes precedence over classes found in -Xbootclasspath/a.
|
|
28 |
* AppCDS does not support uncompressed oops
|
|
29 |
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
|
30 |
* @library /test/lib /test/hotspot/jtreg/runtime/appcds
|
|
31 |
* @modules java.activation
|
|
32 |
* jdk.jartool/sun.tools.jar
|
|
33 |
* @compile ../../test-classes/DummyClassHelper.java
|
|
34 |
* @compile ../../test-classes/java/net/HttpCookie.jasm
|
|
35 |
* @compile ../../test-classes/javax/activation/MimeType.jasm
|
|
36 |
* @build sun.hotspot.WhiteBox
|
|
37 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
|
38 |
* @run main DummyClassesInBootClassPath
|
|
39 |
*/
|
|
40 |
|
|
41 |
import java.io.File;
|
|
42 |
import java.util.List;
|
|
43 |
import java.util.ArrayList;
|
|
44 |
import jdk.test.lib.process.OutputAnalyzer;
|
|
45 |
|
|
46 |
public class DummyClassesInBootClassPath {
|
|
47 |
private static final String METHOD_NAME = "thisClassIsDummy()";
|
|
48 |
|
|
49 |
public static void main(String[] args) throws Exception {
|
|
50 |
String classNames[] = { "java/net/HttpCookie",
|
|
51 |
"javax/activation/MimeType"};
|
|
52 |
JarBuilder.build("dummyClasses", classNames[0], classNames[1]);
|
|
53 |
|
|
54 |
String appJar = TestCommon.getTestJar("dummyClasses.jar");
|
|
55 |
OutputAnalyzer dumpOutput = TestCommon.dump(
|
|
56 |
appJar, classNames, "-Xbootclasspath/a:" + appJar);
|
|
57 |
|
|
58 |
List<String> argsList = new ArrayList<String>();
|
|
59 |
for (int i = 0; i < classNames.length; i++) {
|
|
60 |
argsList.add(classNames[i].replace('/', '.'));
|
|
61 |
}
|
|
62 |
String[] arguments = new String[argsList.size()];
|
|
63 |
arguments = argsList.toArray(arguments);
|
|
64 |
OutputAnalyzer execOutput = TestCommon.execCommon(
|
|
65 |
"-cp", TestCommon.getTestDir("."), "-verbose:class",
|
|
66 |
"--add-modules", "java.activation",
|
|
67 |
"-Xbootclasspath/a:" + appJar, "DummyClassHelper",
|
|
68 |
arguments[0], arguments[1]);
|
|
69 |
for (int i = 0; i < arguments.length; i++) {
|
|
70 |
TestCommon.checkExec(execOutput,
|
|
71 |
"java.lang.NoSuchMethodException: " + arguments[i] + "." +
|
|
72 |
METHOD_NAME);
|
|
73 |
}
|
|
74 |
|
|
75 |
JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
|
|
76 |
String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
|
|
77 |
String bootClassPath = "-Xbootclasspath/a:" + appJar +
|
|
78 |
File.pathSeparator + whiteBoxJar;
|
|
79 |
argsList.add("testWithWhiteBox");
|
|
80 |
arguments = new String[argsList.size()];
|
|
81 |
arguments = argsList.toArray(arguments);
|
|
82 |
String[] opts = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
|
83 |
bootClassPath, "-XX:+TraceClassPaths", "DummyClassHelper",
|
|
84 |
arguments[0], arguments[1], arguments[2]};
|
|
85 |
OutputAnalyzer output = TestCommon.execCommon(opts);
|
|
86 |
}
|
|
87 |
}
|
|
88 |
|