hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java
author alanb
Thu, 04 May 2017 07:26:28 +0000
changeset 44993 f61bcd80ec1f
parent 40631 ed82623d7831
permissions -rw-r--r--
8178380: Module system implementation refresh (5/2017) Reviewed-by: lfoltan, hseigel, mchung, sspitsyn Contributed-by: alan.bateman@oracle.com, serguei.spitsyn@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     1
/*
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 40631
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     4
 *
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     8
 *
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    13
 * accompanied this code).
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    14
 *
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    18
 *
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    21
 * questions.
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    22
 */
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    23
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    24
/**
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    25
 * @test
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    26
 * @bug 8159262
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    27
 * @summary layers over the boot layer are repeatedly created, during this iteration, GCs are forced to verify correct walk of module and package lists.
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    28
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    29
 * @library /test/lib
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    30
 * @compile ../CompilerUtils.java
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    31
 * @run main/othervm ModuleStressGC
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    32
 */
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    33
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    34
import java.nio.file.Path;
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    35
import java.nio.file.Paths;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    36
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    37
import jdk.test.lib.process.OutputAnalyzer;
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    38
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    39
public class ModuleStressGC {
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    40
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    41
    private static final String TEST_SRC = System.getProperty("test.src");
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    42
    private static final String TEST_CLASSES = System.getProperty("test.classes");
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    43
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    44
    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    45
    private static final Path MODS_DIR = Paths.get(TEST_CLASSES, "mods");
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    46
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    47
    /**
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    48
     * Compile two module definitions used by the test, jdk.test and jdk.translet.
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    49
     */
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    50
    public static void main(String[] args) throws Exception {
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    51
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    52
        boolean compiled;
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    53
        // Compile module jdk.test declaration
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    54
        compiled = CompilerUtils.compile(
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    55
            SRC_DIR.resolve("jdk.test"),
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    56
            MODS_DIR.resolve("jdk.test"));
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    57
        if (!compiled) {
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    58
            throw new RuntimeException("Test failed to compile module jdk.test");
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    59
        }
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    60
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    61
        // Compile module jdk.translet declaration
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    62
        compiled = CompilerUtils.compile(
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    63
            SRC_DIR.resolve("jdk.translet"),
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    64
            MODS_DIR.resolve("jdk.translet"),
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39616
diff changeset
    65
            "--add-exports=jdk.test/test=jdk.translet",
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39616
diff changeset
    66
            "-p", MODS_DIR.toString());
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    67
        if (!compiled) {
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    68
            throw new RuntimeException("Test failed to compile module jdk.translet");
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    69
        }
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    70
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    71
        // Sanity check that the test, jdk.test/test/MainGC.java,
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    72
        // correctly walks module jdk.test's reads list and package
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    73
        // test's, defined to module jdk.translet, export list at
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    74
        // GC safepoints.
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    75
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
44993
f61bcd80ec1f 8178380: Module system implementation refresh (5/2017)
alanb
parents: 40631
diff changeset
    76
            "-Xlog:module=trace",
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39616
diff changeset
    77
            "-p", MODS_DIR.toString(),
39616
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    78
            "-m", "jdk.test/test.MainGC");
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    79
        OutputAnalyzer oa = new OutputAnalyzer(pb.start());
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    80
        oa.shouldContain("package test defined in module jdk.test, exports list being walked")
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    81
          .shouldContain("module jdk.test reads list being walked")
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    82
          .shouldHaveExitValue(0);
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    83
    }
f82b1f888578 8159262: Walking PackageEntry Export and ModuleEntry Reads Must Occur Only When Neccessary And Wait Until ClassLoader's Aliveness Determined
lfoltan
parents:
diff changeset
    84
}