hotspot/test/runtime/SharedArchiveFile/SharedStrings.java
author alanb
Thu, 17 Mar 2016 19:04:01 +0000
changeset 36508 5f9eee6b383b
parent 33730 30e064828045
child 37263 08dec586ed5c
child 36851 03e2f4d0a421
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, harold.seigel@oracle.com, lois.foltan@oracle.com, calvin.cheung@oracle.com, christian.tornqvist@oracle.com, erik.joelsson@oracle.com, george.triantafillou@oracle.com, igor.ignatyev@oracle.com, ioi.lam@oracle.com, james.laskey@oracle.com, jean-francois.denise@oracle.com, jiangli.zhou@oracle.com, markus.gronlund@oracle.com, serguei.spitsyn@oracle.com, staffan.larsen@oracle.com, sundararajan.athijegannathan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32179
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     1
/*
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 33730
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
32179
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     4
 *
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     8
 *
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    13
 * accompanied this code).
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    14
 *
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    18
 *
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    21
 * questions.
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    22
 */
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    23
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    24
/*
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    25
 * @test
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    26
 * @summary Check to make sure that shared strings in the bootstrap CDS archive
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    27
 *          are actually shared
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    28
 * Feature support: G1GC only, compressed oops/kptrs, 64-bit os, not on windows
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    29
 * @requires (sun.arch.data.model != "32") & (os.family != "windows")
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    30
 * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    31
 * @requires (vm.gc=="G1" | vm.gc=="null")
33730
30e064828045 8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents: 32615
diff changeset
    32
 * @library /testlibrary /test/lib
32179
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    33
 * @modules java.base/sun.misc
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    34
 *          java.management
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 33730
diff changeset
    35
 *          jdk.jartool/sun.tools.jar
32615
b6c0aafd6945 8133180: [TESTBUG] runtime/SharedArchiveFile/SharedStrings.java failed with WhiteBox.class : no such file or directory
mseledtsov
parents: 32197
diff changeset
    36
 * @build SharedStringsWb SharedStrings BasicJarBuilder sun.hotspot.WhiteBox
32179
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    37
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    38
 * @run main SharedStrings
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    39
 */
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    40
import jdk.test.lib.*;
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    41
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    42
public class SharedStrings {
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    43
    public static void main(String[] args) throws Exception {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 33730
diff changeset
    44
        BasicJarBuilder.build(true, "whitebox", "sun/hotspot/WhiteBox");
32179
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    45
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    46
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    47
            "-XX:+UnlockDiagnosticVMOptions",
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    48
            "-XX:SharedArchiveFile=./SharedStrings.jsa",
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    49
            "-XX:+PrintSharedSpaces",
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    50
            // Needed for bootclasspath match, for CDS to work with WhiteBox API
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    51
            "-Xbootclasspath/a:" + BasicJarBuilder.getTestJar("whitebox.jar"),
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    52
            "-Xshare:dump");
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    53
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    54
        new OutputAnalyzer(pb.start())
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    55
            .shouldContain("Loading classes to share")
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    56
            .shouldContain("Shared string table stats")
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    57
            .shouldHaveExitValue(0);
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    58
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    59
        pb = ProcessTools.createJavaProcessBuilder(
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    60
            "-XX:+UnlockDiagnosticVMOptions",
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    61
            "-XX:SharedArchiveFile=./SharedStrings.jsa",
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    62
            // these are required modes for shared strings
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    63
            "-XX:+UseCompressedOops", "-XX:+UseG1GC",
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    64
            // needed for access to white box test API
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    65
            "-Xbootclasspath/a:" + BasicJarBuilder.getTestJar("whitebox.jar"),
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    66
            "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    67
            "-Xshare:on", "-showversion", "SharedStringsWb");
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    68
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    69
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    70
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    71
        try {
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    72
            output.shouldContain("sharing");
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    73
            output.shouldHaveExitValue(0);
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    74
        } catch (RuntimeException e) {
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    75
            output.shouldContain("Unable to use shared archive");
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    76
            output.shouldHaveExitValue(1);
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    77
        }
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    78
    }
246b2ef581b2 8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff changeset
    79
}