< prev index next >

test/hotspot/jtreg/runtime/appcds/UseAppCDS.java

Print this page


  91         dumpArchive(false, new String[] { BOOTCLASS },
  92                     new String[] { TESTNAME});
  93 
  94         // Test 4:    AppCDS - "test" classes in classlist are dumped
  95         dumpArchive(true, new String[] { BOOTCLASS, TESTNAME },
  96                     new String[0]);
  97 
  98         // Next tests rely on the archive we just dumped
  99 
 100         // Test 5: No AppCDS - Using archive containing "test" classes ignores them
 101         useArchive(false, new String[] { BOOTCLASS },
 102                    new String[] { TESTNAME });
 103 
 104         // Test 6:    AppCDS - Using archive containing "test" classes loads them
 105         useArchive(true, new String[] { BOOTCLASS, TESTNAME },
 106                    new String[0]);
 107     }
 108 
 109     public static List<String> toClassNames(String filename) throws IOException {
 110         ArrayList<String> classes = new ArrayList<>();
 111         BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
 112         for (; ; ) {
 113             String line = br.readLine();
 114             if (line == null)
 115                 break;

 116             classes.add(line.replaceAll("/", "."));

 117         }
 118         return classes;
 119     }
 120 
 121     static void dumpLoadedClasses(boolean useAppCDS, String[] expectedClasses,
 122                                   String[] unexpectedClasses) throws Exception {
 123         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 124             true,
 125             "-XX:DumpLoadedClassList=" + CLASSLIST_FILE,
 126             "-cp",
 127             TESTJAR,
 128             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
 129             TESTNAME,
 130             TEST_OUT);
 131 
 132         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes")
 133             .shouldHaveExitValue(0).shouldContain(TEST_OUT);
 134 
 135         List<String> dumpedClasses = toClassNames(CLASSLIST_FILE);
 136 




  91         dumpArchive(false, new String[] { BOOTCLASS },
  92                     new String[] { TESTNAME});
  93 
  94         // Test 4:    AppCDS - "test" classes in classlist are dumped
  95         dumpArchive(true, new String[] { BOOTCLASS, TESTNAME },
  96                     new String[0]);
  97 
  98         // Next tests rely on the archive we just dumped
  99 
 100         // Test 5: No AppCDS - Using archive containing "test" classes ignores them
 101         useArchive(false, new String[] { BOOTCLASS },
 102                    new String[] { TESTNAME });
 103 
 104         // Test 6:    AppCDS - Using archive containing "test" classes loads them
 105         useArchive(true, new String[] { BOOTCLASS, TESTNAME },
 106                    new String[0]);
 107     }
 108 
 109     public static List<String> toClassNames(String filename) throws IOException {
 110         ArrayList<String> classes = new ArrayList<>();
 111         try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename)))) {
 112             for (; ; ) {
 113                 String line = br.readLine();
 114                 if (line == null) {
 115                     break;
 116                 }
 117                 classes.add(line.replaceAll("/", "."));
 118             }
 119         }
 120         return classes;
 121     }
 122 
 123     static void dumpLoadedClasses(boolean useAppCDS, String[] expectedClasses,
 124                                   String[] unexpectedClasses) throws Exception {
 125         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 126             true,
 127             "-XX:DumpLoadedClassList=" + CLASSLIST_FILE,
 128             "-cp",
 129             TESTJAR,
 130             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
 131             TESTNAME,
 132             TEST_OUT);
 133 
 134         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes")
 135             .shouldHaveExitValue(0).shouldContain(TEST_OUT);
 136 
 137         List<String> dumpedClasses = toClassNames(CLASSLIST_FILE);
 138 


< prev index next >