< prev index next >

test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java

Print this page

40 import java.util.Arrays;
41 
42 import jdk.test.lib.Platform;
43 import jdk.test.lib.process.ProcessTools;
44 import jdk.test.lib.process.OutputAnalyzer;
45 
46 public class TestSharedArchiveWithPreTouch {
47     public static void main(String[] args) throws Exception {
48         final String ArchiveFileName = "./SharedArchiveWithPreTouch.jsa";
49 
50         final List<String> BaseOptions = Arrays.asList(new String[] {"-XX:+UseG1GC", "-XX:+AlwaysPreTouch",
51             "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + ArchiveFileName });
52 
53         ProcessBuilder pb;
54 
55         List<String> dump_args = new ArrayList<String>(BaseOptions);
56 
57         if (Platform.is64bit()) {
58           dump_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" }));
59         }
60         dump_args.addAll(Arrays.asList(new String[] { "-Xshare:dump", "-Xlog:cds" }));
61 
62         pb = ProcessTools.createJavaProcessBuilder(dump_args);
63         OutputAnalyzer output = new OutputAnalyzer(pb.start());

64         try {
65             output.shouldContain("Loading classes to share");
66             output.shouldHaveExitValue(0);
67 
68             List<String> load_args = new ArrayList<String>(BaseOptions);
69 
70             if (Platform.is64bit()) {
71                 load_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" }));
72             }
73             load_args.addAll(Arrays.asList(new String[] { "-Xshare:on", "-version" }));
74 
75             pb = ProcessTools.createJavaProcessBuilder(load_args.toArray(new String[0]));
76             output = new OutputAnalyzer(pb.start());

77             output.shouldContain("sharing");
78             output.shouldHaveExitValue(0);
79         } catch (RuntimeException e) {
80             // Report 'passed' if CDS was turned off.
81             output.shouldContain("Unable to use shared archive");
82             output.shouldHaveExitValue(1);
83         }
84     }
85 }

40 import java.util.Arrays;
41 
42 import jdk.test.lib.Platform;
43 import jdk.test.lib.process.ProcessTools;
44 import jdk.test.lib.process.OutputAnalyzer;
45 
46 public class TestSharedArchiveWithPreTouch {
47     public static void main(String[] args) throws Exception {
48         final String ArchiveFileName = "./SharedArchiveWithPreTouch.jsa";
49 
50         final List<String> BaseOptions = Arrays.asList(new String[] {"-XX:+UseG1GC", "-XX:+AlwaysPreTouch",
51             "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + ArchiveFileName });
52 
53         ProcessBuilder pb;
54 
55         List<String> dump_args = new ArrayList<String>(BaseOptions);
56 
57         if (Platform.is64bit()) {
58           dump_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" }));
59         }
60         dump_args.addAll(Arrays.asList(new String[] { "-Xshare:dump", "-Xlog:cds*", "-Xlog:metaspace*" }));
61 
62         pb = ProcessTools.createJavaProcessBuilder(dump_args);
63         OutputAnalyzer output = new OutputAnalyzer(pb.start());
64         output.reportDiagnosticSummary();
65         try {
66             output.shouldContain("Loading classes to share");
67             output.shouldHaveExitValue(0);
68 
69             List<String> load_args = new ArrayList<String>(BaseOptions);
70 
71             if (Platform.is64bit()) {
72                 load_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" }));
73             }
74             load_args.addAll(Arrays.asList(new String[] { "-Xshare:on", "-Xlog:cds*", "-Xlog:metaspace*", "-version" }));
75 
76             pb = ProcessTools.createJavaProcessBuilder(load_args.toArray(new String[0]));
77             output = new OutputAnalyzer(pb.start());
78             output.reportDiagnosticSummary();
79             output.shouldContain("sharing");
80             output.shouldHaveExitValue(0);
81         } catch (RuntimeException e) {
82             // Report 'passed' if CDS was turned off.
83             output.shouldContain("Unable to use shared archive");
84             output.shouldHaveExitValue(1);
85         }
86     }
87 }
< prev index next >