test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/hotspot/jtreg/runtime/appcds/javaldr

test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java

Print this page




  45 import jdk.test.lib.process.ProcessTools;
  46 import sun.hotspot.WhiteBox;
  47 
  48 public class GCSharedStringsDuringDump {
  49     public static String appClasses[] = {
  50         "GCSharedStringsDuringDumpWb",
  51     };
  52     public static String agentClasses[] = {
  53         "GCDuringDumpTransformer",
  54     };
  55 
  56     public static void main(String[] args) throws Throwable {
  57         String agentJar =
  58             ClassFileInstaller.writeJar("GCDuringDumpTransformer.jar",
  59                                         ClassFileInstaller.Manifest.fromSourceFile("GCDuringDumpTransformer.mf"),
  60                                         agentClasses);
  61 
  62         String appJar =
  63             ClassFileInstaller.writeJar("GCSharedStringsDuringDumpApp.jar", appClasses);
  64 
  65         String gcLog = "-Xlog:gc*=info,gc+region=trace,gc+alloc+region=debug";
  66 
  67         String sharedArchiveCfgFile =
  68             System.getProperty("user.dir") + File.separator + "GCSharedStringDuringDump_gen.txt";
  69         try (FileOutputStream fos = new FileOutputStream(sharedArchiveCfgFile)) {
  70             PrintWriter out = new PrintWriter(new OutputStreamWriter(fos));
  71             out.println("VERSION: 1.0");
  72             out.println("@SECTION: String");
  73             out.println("31: shared_test_string_unique_14325");
  74             for (int i=0; i<100000; i++) {
  75                 String s = "generated_string " + i;
  76                 out.println(s.length() + ": " + s);
  77             }
  78             out.close();
  79         }
  80 
  81         JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
  82         String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
  83         String bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar;
  84 
  85         for (int i=0; i<2; i++) {
  86             // i = 0 -- run without agent = no extra GCs
  87             // i = 1 -- run with agent = cause extra GCs
  88 
  89             String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar;
  90 
  91             OutputAnalyzer output = TestCommon.dump(
  92                                 appJar, TestCommon.list("GCSharedStringsDuringDumpWb"),
  93                                 bootClassPath, extraArg, "-Xmx32m", gcLog,
  94                                 "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile);
  95 
  96             if (output.getStdout().contains("Too many string space regions") ||
  97                 output.getStderr().contains("Unable to write archive heap memory regions") ||
  98                 output.getStdout().contains("Try increasing NewSize") ||
  99                 !output.getStdout().contains("oa0 space:") ||
 100                 output.getExitValue() != 0) {
 101                 // Try again with larger heap and NewSize, this should increase the
 102                 // G1 heap region size to 2M
 103                 TestCommon.testDump(
 104                     appJar, TestCommon.list("GCSharedStringsDuringDumpWb"),
 105                     bootClassPath, extraArg, "-Xmx8g", "-XX:NewSize=8m", gcLog,
 106                     "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile);
 107             }
 108 
 109             TestCommon.run(
 110                 "-cp", appJar,
 111                 bootClassPath,
 112                 "-Xmx32m",
 113                 "-XX:+PrintSharedSpaces",
 114                 "-XX:+UnlockDiagnosticVMOptions",
 115                 "-XX:+WhiteBoxAPI",
 116                 "-XX:SharedReadOnlySize=30m",
 117                 gcLog,
 118                 "GCSharedStringsDuringDumpWb")
 119               .assertNormalExit();
 120         }
 121     }
 122 }
 123 


  45 import jdk.test.lib.process.ProcessTools;
  46 import sun.hotspot.WhiteBox;
  47 
  48 public class GCSharedStringsDuringDump {
  49     public static String appClasses[] = {
  50         "GCSharedStringsDuringDumpWb",
  51     };
  52     public static String agentClasses[] = {
  53         "GCDuringDumpTransformer",
  54     };
  55 
  56     public static void main(String[] args) throws Throwable {
  57         String agentJar =
  58             ClassFileInstaller.writeJar("GCDuringDumpTransformer.jar",
  59                                         ClassFileInstaller.Manifest.fromSourceFile("GCDuringDumpTransformer.mf"),
  60                                         agentClasses);
  61 
  62         String appJar =
  63             ClassFileInstaller.writeJar("GCSharedStringsDuringDumpApp.jar", appClasses);
  64 


  65         String sharedArchiveCfgFile =
  66             System.getProperty("user.dir") + File.separator + "GCSharedStringDuringDump_gen.txt";
  67         try (FileOutputStream fos = new FileOutputStream(sharedArchiveCfgFile)) {
  68             PrintWriter out = new PrintWriter(new OutputStreamWriter(fos));
  69             out.println("VERSION: 1.0");
  70             out.println("@SECTION: String");
  71             out.println("31: shared_test_string_unique_14325");
  72             for (int i=0; i<100000; i++) {
  73                 String s = "generated_string " + i;
  74                 out.println(s.length() + ": " + s);
  75             }
  76             out.close();
  77         }
  78 
  79         JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
  80         String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
  81         String bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar;
  82 
  83         for (int i=0; i<2; i++) {
  84             // i = 0 -- run without agent = no extra GCs
  85             // i = 1 -- run with agent = cause extra GCs
  86 
  87             String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar;
  88 
  89             OutputAnalyzer output = TestCommon.dump(
  90                                 appJar, TestCommon.list("GCSharedStringsDuringDumpWb"),
  91                                 bootClassPath, extraArg, "-Xmx32m",
  92                                 "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile);
  93 
  94             if (output.getStdout().contains("Too many string space regions") ||
  95                 output.getStderr().contains("Unable to write archive heap memory regions") ||
  96                 output.getStdout().contains("Try increasing NewSize") ||
  97                 !output.getStdout().contains("oa0 space:") ||
  98                 output.getExitValue() != 0) {
  99                 // Try again with larger heap and NewSize, this should increase the
 100                 // G1 heap region size to 2M
 101                 TestCommon.testDump(
 102                     appJar, TestCommon.list("GCSharedStringsDuringDumpWb"),
 103                     bootClassPath, extraArg, "-Xmx8g", "-XX:NewSize=8m",
 104                     "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile);
 105             }
 106 
 107             TestCommon.run(
 108                 "-cp", appJar,
 109                 bootClassPath,
 110                 "-Xmx32m",
 111                 "-XX:+PrintSharedSpaces",
 112                 "-XX:+UnlockDiagnosticVMOptions",
 113                 "-XX:+WhiteBoxAPI",
 114                 "-XX:SharedReadOnlySize=30m",

 115                 "GCSharedStringsDuringDumpWb")
 116               .assertNormalExit();
 117         }
 118     }
 119 }
 120 
test/hotspot/jtreg/runtime/appcds/javaldr/GCSharedStringsDuringDump.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File