< prev index next >

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

Print this page

48 
49 public class OldClassVerifierTrouble extends DynamicArchiveTestBase {
50     static final String appClass = "VerifierTroubleApp";
51     static final String baseArchiveClass = "OldSuperVerifierTrouble";
52 
53     public static void main(String[] args) throws Exception {
54         runTest(OldClassVerifierTrouble::testCustomBase);
55     }
56 
57     static void testCustomBase() throws Exception {
58         String topArchiveName = getNewArchiveName("top");
59         doTestCustomBase(topArchiveName);
60     }
61 
62     private static void doTestCustomBase(String topArchiveName) throws Exception {
63         String appJar = ClassFileInstaller.getJarPath("oldsuper-fail-verifier.jar");
64 
65         // create a custom base archive containing an old class
66         OutputAnalyzer output = TestCommon.dump(appJar,
67             TestCommon.list("VerifierTroubleApp", "VerifierTroublev49", "ChildOldSuper"),
68             "-Xlog:class+load,cds+class=debug");

69         TestCommon.checkDump(output);
70         // Check the ChildOldSuper and VerifierTroublev49 are being dumped into the base archive.
71         output.shouldMatch(".cds.class.*klass.*0x.*app.*ChildOldSuper.*unlinked")
72               .shouldMatch(".cds.class.*klass.*0x.*app.*VerifierTroublev49.*unlinked");
73 
74         String baseArchiveName = TestCommon.getCurrentArchiveName();
75 
76         // create a dynamic archive with the custom base archive.
77         // The old class is in the base archive and will be
78         // accessed from VerifierTroubleApp.
79         // Linking VerifierTroublev49 would result in java.lang.VerifyError.
80         dump2(baseArchiveName, topArchiveName,
81               "-Xlog:cds,cds+dynamic,class+load,cds+class=debug",

82               "-cp", appJar,
83               appClass)
84             .assertAbnormalExit(out -> {
85                     out.shouldContain("VerifierTroublev49 source: shared objects file")
86                        .shouldContain("ChildOldSuper source: shared objects file")
87                        .shouldContain("java.lang.VerifyError: " +
88                                       "(class: VerifierTroublev49, method: doit signature: ()Ljava/lang/String;)" +
89                                       " Wrong return type in function");
90                 });
91     }
92 }

48 
49 public class OldClassVerifierTrouble extends DynamicArchiveTestBase {
50     static final String appClass = "VerifierTroubleApp";
51     static final String baseArchiveClass = "OldSuperVerifierTrouble";
52 
53     public static void main(String[] args) throws Exception {
54         runTest(OldClassVerifierTrouble::testCustomBase);
55     }
56 
57     static void testCustomBase() throws Exception {
58         String topArchiveName = getNewArchiveName("top");
59         doTestCustomBase(topArchiveName);
60     }
61 
62     private static void doTestCustomBase(String topArchiveName) throws Exception {
63         String appJar = ClassFileInstaller.getJarPath("oldsuper-fail-verifier.jar");
64 
65         // create a custom base archive containing an old class
66         OutputAnalyzer output = TestCommon.dump(appJar,
67             TestCommon.list("VerifierTroubleApp", "VerifierTroublev49", "ChildOldSuper"),
68             "-Xlog:class+load,cds+class=debug",
69             "-XX:-PreloadSharedClasses");
70         TestCommon.checkDump(output);
71         // Check the ChildOldSuper and VerifierTroublev49 are being dumped into the base archive.
72         output.shouldMatch(".cds.class.*klass.*0x.*app.*ChildOldSuper.*unlinked")
73               .shouldMatch(".cds.class.*klass.*0x.*app.*VerifierTroublev49.*unlinked");
74 
75         String baseArchiveName = TestCommon.getCurrentArchiveName();
76 
77         // create a dynamic archive with the custom base archive.
78         // The old class is in the base archive and will be
79         // accessed from VerifierTroubleApp.
80         // Linking VerifierTroublev49 would result in java.lang.VerifyError.
81         dump2(baseArchiveName, topArchiveName,
82               "-Xlog:cds,cds+dynamic,class+load,cds+class=debug",
83               "-XX:-PreloadSharedClasses",
84               "-cp", appJar,
85               appClass)
86             .assertAbnormalExit(out -> {
87                     out.shouldContain("VerifierTroublev49 source: shared objects file")
88                        .shouldContain("ChildOldSuper source: shared objects file")
89                        .shouldContain("java.lang.VerifyError: " +
90                                       "(class: VerifierTroublev49, method: doit signature: ()Ljava/lang/String;)" +
91                                       " Wrong return type in function");
92                 });
93     }
94 }
< prev index next >