< prev index next >

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

Print this page




  35 public class HelloDynamic extends DynamicArchiveTestBase {
  36     public static void main(String[] args) throws Exception {
  37         runTest(HelloDynamic::testDefaultBase);
  38         runTest(HelloDynamic::testCustomBase);
  39     }
  40 
  41     // (1) Test with default base archive + top archive
  42     static void testDefaultBase() throws Exception {
  43         String topArchiveName = getNewArchiveName("top");
  44         doTest(null, topArchiveName);
  45     }
  46 
  47     // (2) Test with custom base archive + top archive
  48     static void testCustomBase() throws Exception {
  49         String topArchiveName = getNewArchiveName("top2");
  50         String baseArchiveName = getNewArchiveName("base");
  51         dumpBaseArchive(baseArchiveName);
  52         doTest(baseArchiveName, topArchiveName);
  53     }
  54 



  55     private static void doTest(String baseArchiveName, String topArchiveName) throws Exception {
  56         String appJar = ClassFileInstaller.getJarPath("hello.jar");
  57         String mainClass = "Hello";
  58         dump2(baseArchiveName, topArchiveName,
  59              "-Xlog:cds",
  60              "-Xlog:cds+dynamic=debug",
  61              "-cp", appJar, mainClass)
  62             .assertNormalExit(output -> {
  63                     output.shouldContain("Buffer-space to target-space delta")
  64                            .shouldContain("Written dynamic archive 0x");
  65                 });
  66         run2(baseArchiveName, topArchiveName,
  67             "-Xlog:class+load",
  68             "-Xlog:cds+dynamic=debug,cds=debug",
  69             "-cp", appJar, mainClass)
  70             .assertNormalExit(output -> {
  71                     output.shouldContain("Hello source: shared objects file")
  72                           .shouldHaveExitValue(0);
  73                 });














  74     }
  75 }


  35 public class HelloDynamic extends DynamicArchiveTestBase {
  36     public static void main(String[] args) throws Exception {
  37         runTest(HelloDynamic::testDefaultBase);
  38         runTest(HelloDynamic::testCustomBase);
  39     }
  40 
  41     // (1) Test with default base archive + top archive
  42     static void testDefaultBase() throws Exception {
  43         String topArchiveName = getNewArchiveName("top");
  44         doTest(null, topArchiveName);
  45     }
  46 
  47     // (2) Test with custom base archive + top archive
  48     static void testCustomBase() throws Exception {
  49         String topArchiveName = getNewArchiveName("top2");
  50         String baseArchiveName = getNewArchiveName("base");
  51         dumpBaseArchive(baseArchiveName);
  52         doTest(baseArchiveName, topArchiveName);
  53     }
  54 
  55     private static final String JDWP_OPTION =
  56         "-Xrunjdwp:transport=dt_socket,server=y,suspend=n";
  57 
  58     private static void doTest(String baseArchiveName, String topArchiveName) throws Exception {
  59         String appJar = ClassFileInstaller.getJarPath("hello.jar");
  60         String mainClass = "Hello";
  61         dump2(baseArchiveName, topArchiveName,
  62              "-Xlog:cds",
  63              "-Xlog:cds+dynamic=debug",
  64              "-cp", appJar, mainClass)
  65             .assertNormalExit(output -> {
  66                     output.shouldContain("Buffer-space to target-space delta")
  67                            .shouldContain("Written dynamic archive 0x");
  68                 });
  69         run2(baseArchiveName, topArchiveName,
  70             "-Xlog:class+load",
  71             "-Xlog:cds+dynamic=debug,cds=debug",
  72             "-cp", appJar, mainClass)
  73             .assertNormalExit(output -> {
  74                     output.shouldContain("Hello source: shared objects file")
  75                           .shouldHaveExitValue(0);
  76                 });
  77 
  78         // Sanity test with JDWP options.
  79         // Test with the default base archive should be sufficient.
  80         if (baseArchiveName == null) {
  81             run2(baseArchiveName, topArchiveName,
  82                 JDWP_OPTION,
  83                 "-Xlog:class+load",
  84                 "-Xlog:cds+dynamic=debug,cds=debug",
  85                 "-cp", appJar, mainClass)
  86                 .assertNormalExit(output -> {
  87                     output.shouldContain("Hello source: shared objects file")
  88                           .shouldHaveExitValue(0);
  89                     });
  90         }
  91     }
  92 }
< prev index next >