77 for (; ; ) { 78 String line = br.readLine(); 79 if (line == null) { 80 break; 81 } 82 classes.add(line.replaceAll("/", ".")); 83 } 84 } 85 return classes; 86 } 87 88 static void dumpLoadedClasses(String[] expectedClasses) throws Exception { 89 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, 90 TestCommon.makeCommandLineForAppCDS( 91 "-XX:DumpLoadedClassList=" + CLASSLIST_FILE, 92 // trigger JVMCI runtime init so that JVMCI classes will be 93 // included in the classlist 94 "-XX:+EagerJVMCI", 95 "-cp", 96 TESTJAR, 97 "-XX:+UseAppCDS", 98 TESTNAME, 99 TEST_OUT)); 100 101 OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes") 102 .shouldHaveExitValue(0) 103 .shouldContain(TEST_OUT); 104 105 List<String> dumpedClasses = toClassNames(CLASSLIST_FILE); 106 107 for (String clazz : expectedClasses) { 108 if (!dumpedClasses.contains(clazz)) { 109 throw new RuntimeException(clazz + " missing in " + 110 CLASSLIST_FILE); 111 } 112 } 113 } 114 115 static void dumpArchive() throws Exception { 116 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, 117 TestCommon.makeCommandLineForAppCDS( 118 "-cp", 119 TESTJAR, 120 "-XX:+UseAppCDS", 121 "-XX:SharedClassListFile=" + CLASSLIST_FILE, 122 "-XX:SharedArchiveFile=" + ARCHIVE_FILE, 123 "-Xlog:cds", 124 "-Xshare:dump", 125 "-XX:MetaspaceSize=12M", 126 "-XX:MaxMetaspaceSize=12M")); 127 128 OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive"); 129 int exitValue = output.getExitValue(); 130 if (exitValue == 1) { 131 output.shouldContain("Failed allocating metaspace object type"); 132 } else if (exitValue == 0) { 133 output.shouldContain("Loading classes to share"); 134 } else { 135 throw new RuntimeException("Unexpected exit value " + exitValue); 136 } 137 } 138 } | 77 for (; ; ) { 78 String line = br.readLine(); 79 if (line == null) { 80 break; 81 } 82 classes.add(line.replaceAll("/", ".")); 83 } 84 } 85 return classes; 86 } 87 88 static void dumpLoadedClasses(String[] expectedClasses) throws Exception { 89 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, 90 TestCommon.makeCommandLineForAppCDS( 91 "-XX:DumpLoadedClassList=" + CLASSLIST_FILE, 92 // trigger JVMCI runtime init so that JVMCI classes will be 93 // included in the classlist 94 "-XX:+EagerJVMCI", 95 "-cp", 96 TESTJAR, 97 TESTNAME, 98 TEST_OUT)); 99 100 OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes") 101 .shouldHaveExitValue(0) 102 .shouldContain(TEST_OUT); 103 104 List<String> dumpedClasses = toClassNames(CLASSLIST_FILE); 105 106 for (String clazz : expectedClasses) { 107 if (!dumpedClasses.contains(clazz)) { 108 throw new RuntimeException(clazz + " missing in " + 109 CLASSLIST_FILE); 110 } 111 } 112 } 113 114 static void dumpArchive() throws Exception { 115 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, 116 TestCommon.makeCommandLineForAppCDS( 117 "-cp", 118 TESTJAR, 119 "-XX:SharedClassListFile=" + CLASSLIST_FILE, 120 "-XX:SharedArchiveFile=" + ARCHIVE_FILE, 121 "-Xlog:cds", 122 "-Xshare:dump", 123 "-XX:MetaspaceSize=12M", 124 "-XX:MaxMetaspaceSize=12M")); 125 126 OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive"); 127 int exitValue = output.getExitValue(); 128 if (exitValue == 1) { 129 output.shouldContain("Failed allocating metaspace object type"); 130 } else if (exitValue == 0) { 131 output.shouldContain("Loading classes to share"); 132 } else { 133 throw new RuntimeException("Unexpected exit value " + exitValue); 134 } 135 } 136 } |