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 Test the behavior when shared classes loaded by custom loaders are
|
|
28 |
* unloaded.
|
|
29 |
* (NOTE: AppCDS does not support uncompressed oops)
|
|
30 |
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
|
31 |
* @requires (sun.arch.data.model == "64")
|
|
32 |
* @requires ((os.family == "linux") & (os.arch=="amd64")) | (os.family == "solaris")
|
|
33 |
* @library /test/lib /test/hotspot/jtreg/runtime/appcds /test/hotspot/jtreg/runtime/testlibrary
|
|
34 |
* @modules java.base/jdk.internal.misc
|
|
35 |
* java.management
|
|
36 |
* jdk.jartool/sun.tools.jar
|
|
37 |
* @build sun.hotspot.WhiteBox ClassUnloadCommon
|
|
38 |
* @compile test-classes/UnloadUnregisteredLoader.java test-classes/CustomLoadee.java
|
|
39 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
|
40 |
* @run main ClassFileInstaller ClassUnloadCommon
|
|
41 |
* @run main ClassFileInstaller ClassUnloadCommon$1
|
|
42 |
* @run main ClassFileInstaller ClassUnloadCommon$TestFailure
|
|
43 |
* @run main UnloadUnregisteredLoaderTest
|
|
44 |
*/
|
|
45 |
|
|
46 |
import jdk.test.lib.process.OutputAnalyzer;
|
|
47 |
import sun.hotspot.WhiteBox;
|
|
48 |
|
|
49 |
public class UnloadUnregisteredLoaderTest {
|
|
50 |
public static void main(String[] args) throws Exception {
|
|
51 |
String appJar1 = JarBuilder.build("UnloadUnregisteredLoader_app1", "UnloadUnregisteredLoader");
|
|
52 |
String appJar2 = JarBuilder.build(true, "UnloadUnregisteredLoader_app2",
|
|
53 |
"ClassUnloadCommon", "ClassUnloadCommon$1", "ClassUnloadCommon$TestFailure");
|
|
54 |
String customJarPath = JarBuilder.build("UnloadUnregisteredLoader_custom", "CustomLoadee");
|
|
55 |
String wbJar = JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
|
|
56 |
String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar;
|
|
57 |
|
|
58 |
String classpath = TestCommon.concatPaths(appJar1, appJar2);
|
|
59 |
String classlist[] = new String[] {
|
|
60 |
"UnloadUnregisteredLoader",
|
|
61 |
"ClassUnloadCommon",
|
|
62 |
"ClassUnloadCommon$1",
|
|
63 |
"ClassUnloadCommon$TestFailure",
|
|
64 |
"java/lang/Object id: 1",
|
|
65 |
"CustomLoadee id: 2 super: 1 source: " + customJarPath,
|
|
66 |
};
|
|
67 |
|
|
68 |
OutputAnalyzer output;
|
|
69 |
TestCommon.testDump(classpath, classlist,
|
|
70 |
// command-line arguments ...
|
|
71 |
use_whitebox_jar);
|
|
72 |
|
|
73 |
output = TestCommon.exec(classpath,
|
|
74 |
// command-line arguments ...
|
|
75 |
use_whitebox_jar,
|
|
76 |
"-XX:+UnlockDiagnosticVMOptions",
|
|
77 |
"-XX:+WhiteBoxAPI",
|
|
78 |
"UnloadUnregisteredLoader",
|
|
79 |
customJarPath);
|
|
80 |
TestCommon.checkExec(output);
|
|
81 |
}
|
|
82 |
}
|