1 /*
2 * Copyright (c) 2020, 2023, 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 *
34 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. LambdaCustomLoader
35 */
36
37 import jdk.test.lib.helpers.ClassFileInstaller;
38
39 public class LambdaCustomLoader extends DynamicArchiveTestBase {
40 public static void main(String[] args) throws Exception {
41 runTest(LambdaCustomLoader::test);
42 }
43
44 static void test() throws Exception {
45 String topArchiveName = getNewArchiveName();
46 String appJar = ClassFileInstaller.getJarPath("custom_loader_app.jar");
47 String mainClass = "CustomLoaderApp";
48
49 // 1. Host class loaded by a custom loader is initialized during dump time.
50 dump(topArchiveName,
51 "-Xlog:class+load,cds=debug,cds+dynamic",
52 "-cp", appJar, mainClass, appJar, "init", "keep-alive")
53 .assertNormalExit(output -> {
54 output.shouldMatch("Skipping.LambHello[$][$]Lambda.*0x.*:.Hidden.class")
55 .shouldHaveExitValue(0);
56 });
57
58 run(topArchiveName,
59 "-Xlog:class+load,class+unload",
60 "-cp", appJar, mainClass, appJar, "init")
61 .assertNormalExit(output -> {
62 output.shouldMatch("class.load.*LambHello[$][$]Lambda.*0x.*source:.LambHello")
63 .shouldContain("LambHello source: shared objects file (top)")
64 .shouldHaveExitValue(0);
65 });
66
67 // 2. Host class loaded by a custom loader is NOT initialized during dump time.
68 dump(topArchiveName,
69 "-Xlog:class+load,cds=debug,cds+dynamic",
70 "-cp", appJar, mainClass, appJar, "keep-alive")
71 .assertNormalExit(output -> {
72 output.shouldHaveExitValue(0);
73 });
74
|
1 /*
2 * Copyright (c) 2020, 2025, 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 *
34 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. LambdaCustomLoader
35 */
36
37 import jdk.test.lib.helpers.ClassFileInstaller;
38
39 public class LambdaCustomLoader extends DynamicArchiveTestBase {
40 public static void main(String[] args) throws Exception {
41 runTest(LambdaCustomLoader::test);
42 }
43
44 static void test() throws Exception {
45 String topArchiveName = getNewArchiveName();
46 String appJar = ClassFileInstaller.getJarPath("custom_loader_app.jar");
47 String mainClass = "CustomLoaderApp";
48
49 // 1. Host class loaded by a custom loader is initialized during dump time.
50 dump(topArchiveName,
51 "-Xlog:class+load,cds=debug,cds+dynamic",
52 "-cp", appJar, mainClass, appJar, "init", "keep-alive")
53 .assertNormalExit(output -> {
54 output.shouldMatch("Skipping.LambHello[$][$]Lambda.*0x.*:.Unreferenced.hidden.class")
55 .shouldHaveExitValue(0);
56 });
57
58 run(topArchiveName,
59 "-Xlog:class+load,class+unload",
60 "-cp", appJar, mainClass, appJar, "init")
61 .assertNormalExit(output -> {
62 output.shouldMatch("class.load.*LambHello[$][$]Lambda.*0x.*source:.LambHello")
63 .shouldContain("LambHello source: shared objects file (top)")
64 .shouldHaveExitValue(0);
65 });
66
67 // 2. Host class loaded by a custom loader is NOT initialized during dump time.
68 dump(topArchiveName,
69 "-Xlog:class+load,cds=debug,cds+dynamic",
70 "-cp", appJar, mainClass, appJar, "keep-alive")
71 .assertNormalExit(output -> {
72 output.shouldHaveExitValue(0);
73 });
74
|