test/hotspot/jtreg/runtime/appcds/UseAppCDS.java
changeset 48516 7d286141598c
parent 48403 6d4e1efac80a
child 48538 82c3d4173a53
equal deleted inserted replaced
48515:0da9fb7d7d04 48516:7d286141598c
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   120         return classes;
   120         return classes;
   121     }
   121     }
   122 
   122 
   123     static void dumpLoadedClasses(boolean useAppCDS, String[] expectedClasses,
   123     static void dumpLoadedClasses(boolean useAppCDS, String[] expectedClasses,
   124                                   String[] unexpectedClasses) throws Exception {
   124                                   String[] unexpectedClasses) throws Exception {
   125         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   125         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
   126             true,
   126           TestCommon.makeCommandLineForAppCDS(
   127             "-XX:DumpLoadedClassList=" + CLASSLIST_FILE,
   127             "-XX:DumpLoadedClassList=" + CLASSLIST_FILE,
   128             "-cp",
   128             "-cp",
   129             TESTJAR,
   129             TESTJAR,
   130             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
   130             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
   131             TESTNAME,
   131             TESTNAME,
   132             TEST_OUT);
   132             TEST_OUT));
   133 
   133 
   134         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes")
   134         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes")
   135             .shouldHaveExitValue(0).shouldContain(TEST_OUT);
   135             .shouldHaveExitValue(0).shouldContain(TEST_OUT);
   136 
   136 
   137         List<String> dumpedClasses = toClassNames(CLASSLIST_FILE);
   137         List<String> dumpedClasses = toClassNames(CLASSLIST_FILE);
   150         }
   150         }
   151     }
   151     }
   152 
   152 
   153     static void dumpArchive(boolean useAppCDS, String[] expectedClasses,
   153     static void dumpArchive(boolean useAppCDS, String[] expectedClasses,
   154                             String[] unexpectedClasses) throws Exception {
   154                             String[] unexpectedClasses) throws Exception {
   155         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   155         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
   156             true,
   156           TestCommon.makeCommandLineForAppCDS(
   157             useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
   157             useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
   158                         "-XX:+UnlockDiagnosticVMOptions",
   158                         "-XX:+UnlockDiagnosticVMOptions",
   159             "-cp",
   159             "-cp",
   160             TESTJAR,
   160             TESTJAR,
   161             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
   161             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
   162             "-XX:SharedClassListFile=" + CLASSLIST_FILE,
   162             "-XX:SharedClassListFile=" + CLASSLIST_FILE,
   163             "-XX:SharedArchiveFile=" + ARCHIVE_FILE,
   163             "-XX:SharedArchiveFile=" + ARCHIVE_FILE,
   164             "-Xlog:cds",
   164             "-Xlog:cds",
   165             "-Xshare:dump");
   165             "-Xshare:dump"));
   166 
   166 
   167         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive")
   167         OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive")
   168             .shouldHaveExitValue(0);
   168             .shouldHaveExitValue(0);
   169 
   169 
   170         for (String clazz : expectedClasses) {
   170         for (String clazz : expectedClasses) {
   177         }
   177         }
   178     }
   178     }
   179 
   179 
   180     static void useArchive(boolean useAppCDS, String[] expectedClasses,
   180     static void useArchive(boolean useAppCDS, String[] expectedClasses,
   181                            String[] unexpectedClasses) throws Exception {
   181                            String[] unexpectedClasses) throws Exception {
   182         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   182         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
   183             true,
   183           TestCommon.makeCommandLineForAppCDS(
   184             useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
   184             useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
   185                         "-XX:+UnlockDiagnosticVMOptions",
   185                         "-XX:+UnlockDiagnosticVMOptions",
   186             "-cp",
   186             "-cp",
   187             TESTJAR,
   187             TESTJAR,
   188             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
   188             useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
   189             "-XX:SharedArchiveFile=" + ARCHIVE_FILE,
   189             "-XX:SharedArchiveFile=" + ARCHIVE_FILE,
   190             "-verbose:class",
   190             "-verbose:class",
   191             "-Xshare:on",
   191             "-Xshare:on",
   192             TESTNAME,
   192             TESTNAME,
   193             TEST_OUT );
   193             TEST_OUT));
   194 
   194 
   195         OutputAnalyzer output = TestCommon.executeAndLog(pb, "use-archive");
   195         OutputAnalyzer output = TestCommon.executeAndLog(pb, "use-archive");
   196         if (CDSTestUtils.isUnableToMap(output))
   196         if (CDSTestUtils.isUnableToMap(output))
   197             System.out.println("Unable to map: test case skipped");
   197             System.out.println("Unable to map: test case skipped");
   198         else
   198         else