test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java
author kvn
Wed, 13 Dec 2017 11:59:55 -0800
changeset 48397 ead47ddf5844
parent 48171 7ad2d33a0f05
child 48469 7312ae4465d6
permissions -rw-r--r--
8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line Summary: skip tests which use --limit-modules when Graal is used as JIT compiler. Reviewed-by: alanb, mchung, dholmes, ccheung, dnsimon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    23
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    24
/**
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    25
 * @test
48397
ead47ddf5844 8191788: add jdk.internal.vm.compiler to --limit-modules if -Djvmci.Compiler=graal is in the command line
kvn
parents: 48171
diff changeset
    26
 * @requires vm.cds & !vm.graal.enabled
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @summary Testing -Xbootclasspath/a support for CDS
46417
1593c061e6af 8179243: [TESTBUG] CDS tests should be excluded from running with -UseCompressedOops
mseledtsov
parents: 46410
diff changeset
    28
 * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    29
 * @library /test/lib
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 *          java.management
43467
f91da24c6bca 8152206: Simplify jvmstat modules
gtriantafill
parents: 42640
diff changeset
    32
 *          jdk.internal.jvmstat/sun.jvmstat.monitor
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 * @compile javax/sound/sampled/MyClass.jasm
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 * @compile org/omg/CORBA/Context.jasm
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    35
 * @compile nonjdk/myPackage/MyClass.java
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    36
 * @build LoadClass
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    37
 * @run main/othervm BootAppendTests
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    38
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    39
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    40
import java.io.File;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    41
import java.io.FileOutputStream;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    42
import java.io.IOException;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    43
import java.io.PrintStream;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    44
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    45
import java.nio.file.Path;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    46
import java.nio.file.Paths;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    47
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    48
import jdk.test.lib.cds.CDSOptions;
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    49
import jdk.test.lib.cds.CDSTestUtils;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    50
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    51
import jdk.test.lib.process.OutputAnalyzer;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    52
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    53
public class BootAppendTests {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    54
    private static final String APP_CLASS = "LoadClass";
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    private static final String BOOT_APPEND_MODULE_CLASS = "javax/sound/sampled/MyClass";
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    56
    private static final String BOOT_APPEND_DUPLICATE_MODULE_CLASS = "org/omg/CORBA/Context";
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    57
    private static final String BOOT_APPEND_CLASS = "nonjdk/myPackage/MyClass";
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    58
    private static final String BOOT_APPEND_MODULE_CLASS_NAME =
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    59
        BOOT_APPEND_MODULE_CLASS.replace('/', '.');
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    60
    private static final String BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME =
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    61
        BOOT_APPEND_DUPLICATE_MODULE_CLASS.replace('/', '.');
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    62
    private static final String BOOT_APPEND_CLASS_NAME =
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    63
        BOOT_APPEND_CLASS.replace('/', '.');
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    64
    private static final String[] ARCHIVE_CLASSES =
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    65
        {BOOT_APPEND_MODULE_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS, BOOT_APPEND_CLASS};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    66
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    67
    private static final String modes[] = {"on", "off"};
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    68
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    69
    private static String appJar;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    70
    private static String bootAppendJar;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    71
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    72
    public static void main(String... args) throws Exception {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    73
        dumpArchive();
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    74
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    75
        logTestCase("1");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    76
        testBootAppendModuleClass();
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    77
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
    78
        logTestCase("2");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    79
        testBootAppendDuplicateModuleClass();
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    80
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    81
        logTestCase("3");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    82
        testBootAppendExcludedModuleClass();
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    83
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    84
        logTestCase("4");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    85
        testBootAppendDuplicateExcludedModuleClass();
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    86
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    87
        logTestCase("5");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    88
        testBootAppendClass();
48171
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
    89
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
    90
        logTestCase("6");
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
    91
        testBootAppendExtraDir();
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    92
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    93
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    94
    private static void logTestCase(String msg) {
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    95
        System.out.println();
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    96
        System.out.printf("TESTCASE: %s", msg);
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    97
        System.out.println();
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    98
    }
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
    99
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   100
    static void dumpArchive() throws Exception {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   101
        // create the classlist
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   102
        File classlist = CDSTestUtils.makeClassList(ARCHIVE_CLASSES);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   103
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   104
        // build jar files
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   105
        appJar = ClassFileInstaller.writeJar("app.jar", APP_CLASS);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   106
        bootAppendJar = ClassFileInstaller.writeJar("bootAppend.jar",
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   107
            BOOT_APPEND_MODULE_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS, BOOT_APPEND_CLASS);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   108
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   109
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   110
        OutputAnalyzer out = CDSTestUtils.createArchiveAndCheck(
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   111
                                 "-Xbootclasspath/a:" + bootAppendJar,
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   112
                                 "-XX:SharedClassListFile=" + classlist.getPath());
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   113
        // Make sure all the classes were successfully archived.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   114
        for (String archiveClass : ARCHIVE_CLASSES) {
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   115
            out.shouldNotContain("Preload Warning: Cannot find " + archiveClass);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   116
        }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   117
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   118
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   119
    // Test #1: If a class on -Xbootclasspath/a is from a package defined in
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   120
    //          bootmodules, the class is not loaded at runtime.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   121
    //          Verify the behavior is the same when the class is archived
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   122
    //          with CDS enabled at runtime.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   123
    //
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   124
    //          The javax.sound.sampled package is defined in the java.desktop module.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   125
    //          The archived javax.sound.sampled.MyClass from the -Xbootclasspath/a
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   126
    //          should not be loaded at runtime.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   127
    public static void testBootAppendModuleClass() throws Exception {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   128
        for (String mode : modes) {
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   129
            CDSOptions opts = (new CDSOptions())
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   130
                .setXShareMode(mode).setUseVersion(false)
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   131
                .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar, "-showversion")
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   132
                .addSuffix(APP_CLASS, BOOT_APPEND_MODULE_CLASS_NAME);
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   133
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   134
            OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   135
            CDSTestUtils.checkExec(out, opts, "java.lang.ClassNotFoundException: javax.sound.sampled.MyClass");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   136
        }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   137
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   138
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   139
    // Test #2: If a class on -Xbootclasspath/a has the same fully qualified
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   140
    //          name as a class defined in boot modules, the class is not loaded
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   141
    //          from -Xbootclasspath/a. Verify the behavior is the same at runtime
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   142
    //          when CDS is enabled.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   143
    //
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   144
    //          The org.omg.CORBA.Context is a boot module class. The class on
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   145
    //          the -Xbootclasspath/a path that has the same fully-qualified name
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   146
    //          should not be loaded at runtime when CDS is enabled.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   147
    //          The one from the boot modules should be loaded instead.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   148
    public static void testBootAppendDuplicateModuleClass() throws Exception {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   149
        for (String mode : modes) {
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   150
            CDSOptions opts = (new CDSOptions())
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   151
                .setXShareMode(mode).setUseVersion(false)
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   152
                .addPrefix("--add-modules", "java.corba", "-showversion",
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   153
                           "-Xbootclasspath/a:" + bootAppendJar, "-cp", appJar)
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   154
                .addSuffix("-Xlog:class+load=info",
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   155
                           APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   156
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   157
            OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   158
            CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context source: jrt:/java.corba");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   159
        }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   160
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   161
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   162
    // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   163
    //          the class can be loaded from -Xbootclasspath/a when the module is excluded
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 38151
diff changeset
   164
    //          using --limit-modules. Verify the behavior is the same at runtime when CDS
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 38151
diff changeset
   165
    //          is enabled.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   166
    //
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 38151
diff changeset
   167
    //          The java.desktop module is excluded using --limit-modules at runtime,
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   168
    //          javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   169
    //          loaded from the archive at runtime.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   170
    public static void testBootAppendExcludedModuleClass() throws Exception {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   171
        for (String mode : modes) {
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   172
            CDSOptions opts = (new CDSOptions())
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   173
                .setXShareMode(mode).setUseVersion(false)
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   174
                .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
48023
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
   175
                           "--limit-modules=java.base", "-cp", appJar)
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   176
                .addSuffix("-Xlog:class+load=info",
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   177
                           APP_CLASS, BOOT_APPEND_MODULE_CLASS_NAME);
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   178
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   179
            OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   180
            CDSTestUtils.checkExec(out, opts, "[class,load] javax.sound.sampled.MyClass");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   181
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   182
            // When CDS is enabled, the shared class should be loaded from the archive.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   183
            if (mode.equals("on")) {
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   184
                CDSTestUtils.checkExec(out, opts, "[class,load] javax.sound.sampled.MyClass source: shared objects file");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   185
            }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   186
        }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   187
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   188
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   189
    // Test #4: If a class on -Xbootclasspath/a has the same fully qualified
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   190
    //          name as a class defined in boot modules, the class is loaded
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   191
    //          from -Xbootclasspath/a when the boot module is excluded using
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 38151
diff changeset
   192
    //          --limit-modules. Verify the behavior is the same at runtime
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 38151
diff changeset
   193
    //          when CDS is enabled.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   194
    //
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   195
    //          The org.omg.CORBA.Context is a boot module class. The class
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   196
    //          on -Xbootclasspath/a that has the same fully-qualified name
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   197
    //          as org.omg.CORBA.Context can be loaded at runtime when
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   198
    //          java.corba is excluded.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   199
    public static void testBootAppendDuplicateExcludedModuleClass() throws Exception {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   200
        for (String mode : modes) {
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   201
            CDSOptions opts = (new CDSOptions())
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   202
                .setXShareMode(mode).setUseVersion(false)
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   203
                .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
48023
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
   204
                           "--limit-modules=java.base", "-cp", appJar)
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   205
                .addSuffix("-Xlog:class+load=info",
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   206
                           APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   207
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   208
            OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   209
            CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context");
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   210
            if (!CDSTestUtils.isUnableToMap(out)) {
47103
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46779
diff changeset
   211
                if (mode.equals("off")) {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46779
diff changeset
   212
                    out.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar");
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46779
diff changeset
   213
                } else {
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46779
diff changeset
   214
                    CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context source: shared objects file");
a993ec29ec75 8186842: Use Java class loaders for creating the CDS archive
ccheung
parents: 46779
diff changeset
   215
                }
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   216
            }
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   217
        }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   218
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   219
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   220
    // Test #5: If a class on -Xbootclasspath/a is not from named modules,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   221
    //          the class can be loaded at runtime. Verify the behavior is
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   222
    //          the same at runtime when CDS is enabled.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   223
    //
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   224
    //          The nonjdk.myPackage is not defined in named modules. The
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   225
    //          archived nonjdk.myPackage.MyClass from -Xbootclasspath/a
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   226
    //          can be loaded at runtime when CDS is enabled.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   227
    public static void testBootAppendClass() throws Exception {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   228
        for (String mode : modes) {
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   229
            CDSOptions opts = (new CDSOptions())
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   230
                .setXShareMode(mode).setUseVersion(false)
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   231
                .addPrefix("-Xbootclasspath/a:" + bootAppendJar, "-showversion",
48023
4b7462e3b552 8191653: Test failures in BootAppendTests - missing jdk.internal.vm.compiler module
ccheung
parents: 48004
diff changeset
   232
                           "--limit-modules=java.base", "-cp", appJar)
46389
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   233
                .addSuffix("-Xlog:class+load=info",
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   234
                           APP_CLASS, BOOT_APPEND_CLASS_NAME);
d55896236dfd 8177728: [TESTBUG] Improve CDS test utils
mseledtsov
parents: 43467
diff changeset
   235
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   236
            OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   237
            CDSTestUtils.checkExec(out, opts, "[class,load] nonjdk.myPackage.MyClass");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   238
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   239
            // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   240
            // from the shared archive.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   241
            if (mode.equals("on")) {
46410
5ffd0f5000cc 8179103: [Testbug] re-enable the runtime/SharedArchiveFile/BootAppendTests.java test
ccheung
parents: 46389
diff changeset
   242
                CDSTestUtils.checkExec(out, opts,
38151
fffedc5e5cf8 8154110: Update class* and safepoint* logging subsystems
mockner
parents: 37263
diff changeset
   243
                    "[class,load] nonjdk.myPackage.MyClass source: shared objects file");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   244
            }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   245
        }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   246
    }
48171
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   247
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   248
    // Test #6: This is similar to Test #5. During runtime, an extra dir
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   249
    //          is appended to the bootclasspath. It should not invalidate
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   250
    //          the shared archive.
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   251
    public static void testBootAppendExtraDir() throws Exception {
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   252
        for (String mode : modes) {
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   253
            CDSOptions opts = (new CDSOptions())
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   254
                .setXShareMode(mode).setUseVersion(false)
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   255
                .addPrefix("-Xbootclasspath/a:" + bootAppendJar + File.pathSeparator + appJar,
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   256
                           "-showversion", "--limit-modules=java.base", "-cp", appJar)
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   257
                .addSuffix("-Xlog:class+load=info",
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   258
                           APP_CLASS, BOOT_APPEND_CLASS_NAME);
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   259
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   260
            OutputAnalyzer out = CDSTestUtils.runWithArchive(opts);
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   261
            CDSTestUtils.checkExec(out, opts, "[class,load] nonjdk.myPackage.MyClass");
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   262
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   263
            // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   264
            // from the shared archive.
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   265
            if (mode.equals("on")) {
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   266
                CDSTestUtils.checkExec(out, opts,
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   267
                    "[class,load] nonjdk.myPackage.MyClass source: shared objects file");
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   268
            }
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   269
        }
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48023
diff changeset
   270
    }
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
   271
}