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 a simple test for loading a class using the ext class loader in AppCDS
|
|
28 |
* AppCDS does not support uncompressed oops
|
|
29 |
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
|
30 |
* @library /test/lib
|
|
31 |
* @modules java.base/jdk.internal.misc
|
|
32 |
* java.management
|
|
33 |
* jdk.jartool/sun.tools.jar
|
|
34 |
* jdk.internal.jvmstat/sun.jvmstat.monitor
|
|
35 |
* @compile test-classes/HelloExt.java
|
|
36 |
* @build sun.hotspot.WhiteBox
|
|
37 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
|
38 |
* @run main HelloExtTest
|
|
39 |
*/
|
|
40 |
|
|
41 |
import jdk.test.lib.process.OutputAnalyzer;
|
|
42 |
|
|
43 |
public class HelloExtTest {
|
|
44 |
|
|
45 |
public static void main(String[] args) throws Exception {
|
|
46 |
JarBuilder.build("helloExt", "HelloExt");
|
|
47 |
|
|
48 |
String appJar = TestCommon.getTestJar("helloExt.jar");
|
|
49 |
JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
|
|
50 |
String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
|
|
51 |
String bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar;
|
|
52 |
|
|
53 |
TestCommon.dump(appJar,
|
|
54 |
TestCommon.list("org/omg/CORBA/ORB", "[Ljava/lang/Comparable;"),
|
|
55 |
bootClassPath, "-verbose:class", "--add-modules", "java.corba");
|
|
56 |
|
|
57 |
OutputAnalyzer output = TestCommon.execCommon("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
|
58 |
"-cp", appJar, bootClassPath, "-verbose:class", "--add-modules", "java.corba", "HelloExt");
|
|
59 |
|
|
60 |
String prefix = ".class.load. ";
|
|
61 |
String class_pattern = ".*LambdaForm[$]MH[/][0123456789].*";
|
|
62 |
String suffix = ".*source: shared objects file.*";
|
|
63 |
String pattern = prefix + class_pattern + suffix;
|
|
64 |
output.shouldNotMatch(pattern);
|
|
65 |
|
|
66 |
output = TestCommon.execCommon("-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
|
|
67 |
"-cp", appJar, bootClassPath, "-verbose:class",
|
|
68 |
"-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary",
|
|
69 |
"--add-modules", "java.corba", "HelloExt");
|
|
70 |
output.shouldNotMatch(class_pattern);
|
|
71 |
}
|
|
72 |
}
|