< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForOldInfInBaseArchive.java

Print this page

44 
45 public class LambdaForOldInfInBaseArchive extends DynamicArchiveTestBase {
46     static final String classList = CDSTestUtils.getOutputFileName("classlist");
47     static final String appClass = "LambdaContainsOldInfApp";
48     static final String baseArchiveClass = "OldProvider";
49 
50     public static void main(String[] args) throws Exception {
51         runTest(LambdaForOldInfInBaseArchive::testCustomBase);
52     }
53 
54     static void testCustomBase() throws Exception {
55         String topArchiveName = getNewArchiveName("top");
56         doTestCustomBase(topArchiveName);
57     }
58 
59     private static void doTestCustomBase(String topArchiveName) throws Exception {
60         String appJar = ClassFileInstaller.getJarPath("old-inf-base-archive.jar");
61 
62         // create a custom base archive containing and old interface
63         OutputAnalyzer output = TestCommon.dump(appJar,
64             TestCommon.list("OldProvider"), "-Xlog:class+load,cds+class=debug");

65         TestCommon.checkDump(output);
66         // Check that the OldProvider is being dumped into the base archive.
67         output.shouldMatch(".cds,class.*klass.*0x.*app.*OldProvider.*unlinked");
68 
69         String baseArchiveName = TestCommon.getCurrentArchiveName();
70 
71         // create a dynamic archive with the custom base archive.
72         // The old interface is in the base archive and will be
73         // accessed using a lambda expression of LambdaContainsOldInfApp.
74         // The lambda proxy class and the app class will be archived in the dynamic archive.
75         dump2(baseArchiveName, topArchiveName,
76               "-Xlog:cds,cds+dynamic,class+load,cds+class=debug",
77               "-cp", appJar,

78               appClass)
79             .assertNormalExit(out -> {
80                     out.shouldContain("OldProvider source: shared objects file")
81                        .shouldMatch("Archiving hidden LambdaContainsOldInfApp[$][$]Lambda*");
82                 });
83 
84         // Run with both base and dynamic archives. The OldProvider class
85         // should be loaded from the base archive. The LambdaContainsOldInfApp
86         // and its lambda proxy class should be loaded from the dynamic archive.
87         run2(baseArchiveName, topArchiveName,
88               "-Xlog:cds,cds+dynamic,class+load",
89               "-cp", appJar,
90               appClass)
91             .assertNormalExit(out -> {
92                     out.shouldContain("OldProvider source: shared objects file")
93                        .shouldContain("LambdaContainsOldInfApp source: shared objects file (top)")
94                        .shouldMatch(".class.load. LambdaContainsOldInfApp[$][$]Lambda.*/0x.*source:.*shared.*objects.*file.*(top)");
95                 });
96     }
97 }

44 
45 public class LambdaForOldInfInBaseArchive extends DynamicArchiveTestBase {
46     static final String classList = CDSTestUtils.getOutputFileName("classlist");
47     static final String appClass = "LambdaContainsOldInfApp";
48     static final String baseArchiveClass = "OldProvider";
49 
50     public static void main(String[] args) throws Exception {
51         runTest(LambdaForOldInfInBaseArchive::testCustomBase);
52     }
53 
54     static void testCustomBase() throws Exception {
55         String topArchiveName = getNewArchiveName("top");
56         doTestCustomBase(topArchiveName);
57     }
58 
59     private static void doTestCustomBase(String topArchiveName) throws Exception {
60         String appJar = ClassFileInstaller.getJarPath("old-inf-base-archive.jar");
61 
62         // create a custom base archive containing and old interface
63         OutputAnalyzer output = TestCommon.dump(appJar,
64             TestCommon.list("OldProvider"), "-Xlog:class+load,cds+class=debug",
65             "-XX:-PreloadSharedClasses");
66         TestCommon.checkDump(output);
67         // Check that the OldProvider is being dumped into the base archive.
68         output.shouldMatch(".cds,class.*klass.*0x.*app.*OldProvider.*unlinked");
69 
70         String baseArchiveName = TestCommon.getCurrentArchiveName();
71 
72         // create a dynamic archive with the custom base archive.
73         // The old interface is in the base archive and will be
74         // accessed using a lambda expression of LambdaContainsOldInfApp.
75         // The lambda proxy class and the app class will be archived in the dynamic archive.
76         dump2(baseArchiveName, topArchiveName,
77               "-Xlog:cds,cds+dynamic,class+load,cds+class=debug",
78               "-cp", appJar,
79               "-XX:-PreloadSharedClasses",
80               appClass)
81             .assertNormalExit(out -> {
82                     out.shouldContain("OldProvider source: shared objects file")
83                        .shouldMatch("Archiving hidden LambdaContainsOldInfApp[$][$]Lambda*");
84                 });
85 
86         // Run with both base and dynamic archives. The OldProvider class
87         // should be loaded from the base archive. The LambdaContainsOldInfApp
88         // and its lambda proxy class should be loaded from the dynamic archive.
89         run2(baseArchiveName, topArchiveName,
90               "-Xlog:cds,cds+dynamic,class+load",
91               "-cp", appJar,
92               appClass)
93             .assertNormalExit(out -> {
94                     out.shouldContain("OldProvider source: shared objects file")
95                        .shouldContain("LambdaContainsOldInfApp source: shared objects file (top)")
96                        .shouldMatch(".class.load. LambdaContainsOldInfApp[$][$]Lambda.*/0x.*source:.*shared.*objects.*file.*(top)");
97                 });
98     }
99 }
< prev index next >