< prev index next >

test/hotspot/jtreg/runtime/cds/DeterministicDump.java

Print this page

 65         String baseArchive2 = dump(baseArgs);
 66         compare(baseArchive, baseArchive2);
 67 
 68         // (2) This will cause the archive to be relocated during dump time. We should
 69         //     still get the same bits. This simulates relocation that happens when
 70         //     Address Space Layout Randomization prevents the archive space to
 71         //     be mapped at the default location.
 72         String relocatedArchive = dump(baseArgs, "-XX:+UnlockDiagnosticVMOptions", "-XX:ArchiveRelocationMode=1");
 73         compare(baseArchive, relocatedArchive);
 74     }
 75 
 76     static int id = 0;
 77     static String dump(ArrayList<String> args, String... more) throws Exception {
 78         String logName = "SharedArchiveFile" + (id++);
 79         String archiveName = logName + ".jsa";
 80         String mapName = logName + ".map";
 81         CDSOptions opts = (new CDSOptions())
 82             .addPrefix("-Xint") // Override any -Xmixed/-Xcomp flags from jtreg -vmoptions
 83             .addPrefix("-Xlog:cds=debug")
 84             .addPrefix("-Xlog:cds+map*=trace:file=" + mapName + ":none:filesize=0")



 85             .setArchiveName(archiveName)
 86             .addSuffix(args)
 87             .addSuffix(more);
 88         CDSTestUtils.createArchiveAndCheck(opts);
 89 
 90         return archiveName;
 91     }
 92 
 93     static void compare(String file0, String file1) throws Exception {
 94         byte[] buff0 = new byte[4096];
 95         byte[] buff1 = new byte[4096];
 96         try (FileInputStream in0 = new FileInputStream(file0);
 97              FileInputStream in1 = new FileInputStream(file1)) {
 98             int total = 0;
 99             while (true) {
100                 int n0 = read(in0, buff0);
101                 int n1 = read(in1, buff1);
102                 if (n0 != n1) {
103                     throw new RuntimeException("File contents (file sizes?) are different after " + total + " bytes; n0 = "
104                                                + n0 + ", n1 = " + n1);

 65         String baseArchive2 = dump(baseArgs);
 66         compare(baseArchive, baseArchive2);
 67 
 68         // (2) This will cause the archive to be relocated during dump time. We should
 69         //     still get the same bits. This simulates relocation that happens when
 70         //     Address Space Layout Randomization prevents the archive space to
 71         //     be mapped at the default location.
 72         String relocatedArchive = dump(baseArgs, "-XX:+UnlockDiagnosticVMOptions", "-XX:ArchiveRelocationMode=1");
 73         compare(baseArchive, relocatedArchive);
 74     }
 75 
 76     static int id = 0;
 77     static String dump(ArrayList<String> args, String... more) throws Exception {
 78         String logName = "SharedArchiveFile" + (id++);
 79         String archiveName = logName + ".jsa";
 80         String mapName = logName + ".map";
 81         CDSOptions opts = (new CDSOptions())
 82             .addPrefix("-Xint") // Override any -Xmixed/-Xcomp flags from jtreg -vmoptions
 83             .addPrefix("-Xlog:cds=debug")
 84             .addPrefix("-Xlog:cds+map*=trace:file=" + mapName + ":none:filesize=0")
 85             .addPrefix("-XX:-PreloadSharedClasses")
 86             .addPrefix("-XX:-ArchiveFieldReferences")
 87             .addPrefix("-XX:-ArchiveMethodReferences")
 88             .setArchiveName(archiveName)
 89             .addSuffix(args)
 90             .addSuffix(more);
 91         CDSTestUtils.createArchiveAndCheck(opts);
 92 
 93         return archiveName;
 94     }
 95 
 96     static void compare(String file0, String file1) throws Exception {
 97         byte[] buff0 = new byte[4096];
 98         byte[] buff1 = new byte[4096];
 99         try (FileInputStream in0 = new FileInputStream(file0);
100              FileInputStream in1 = new FileInputStream(file1)) {
101             int total = 0;
102             while (true) {
103                 int n0 = read(in0, buff0);
104                 int n1 = read(in1, buff1);
105                 if (n0 != n1) {
106                     throw new RuntimeException("File contents (file sizes?) are different after " + total + " bytes; n0 = "
107                                                + n0 + ", n1 = " + n1);
< prev index next >