test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/ClassPathTests.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 57705 7cf02b2c1455
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     1
/*
57567
b000362a89a0 8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents: 51992
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     4
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     8
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    13
 * accompanied this code).
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    14
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    18
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    21
 * questions.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    22
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    23
 */
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    24
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    25
/**
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    26
 * @test
48469
7312ae4465d6 8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents: 48397
diff changeset
    27
 * @requires vm.cds & !vm.graal.enabled
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    28
 * @library ../..
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    29
 * @library /test/lib
57705
7cf02b2c1455 8229267: [TESTBUG] Remove unnecessary @modules dependencies in CDS tests
iklam
parents: 57567
diff changeset
    30
 * @modules jdk.jartool/sun.tools.jar
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    31
 * @compile src/jdk/test/Main.java
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    32
 * @compile src/com/sun/tools/javac/Main.jasm
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
    33
 * @compile src/com/sun/tools/javac/MyMain.jasm
57567
b000362a89a0 8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents: 51992
diff changeset
    34
 * @compile ../../../javax/annotation/processing/FilerException.jasm
51990
6003e034cdd8 8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents: 49894
diff changeset
    35
 * @run driver ClassPathTests
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    36
 * @summary AppCDS tests for testing classpath/package conflicts
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    37
 */
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    38
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    39
/*
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    40
 * These tests will verify that AppCDS will correctly handle archived classes
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    41
 * on the classpath that are in a package that is also exported by the jimage.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    42
 * These classes should fail to load unless --limit-modules is used to hide the
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    43
 * package exported by the jimage. There are 8 variants of this test:
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    44
 *   - With a jimage app package and with a jimage ext package
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    45
 *   - With --limit-modules and without --limit-modules
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    46
 *   - With AppCDS and without AppCDS (to verify behaviour is the same for both).
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    47
 *
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    48
 * There is also a 9th test to verify that when --limit-modules is used, a jimage
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    49
 * class in the archive can be replaced by a classpath class with the
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    50
 * same name and package.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    51
 */
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    52
51992
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    53
import java.lang.reflect.InvocationTargetException;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    54
import java.lang.reflect.Method;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    55
import java.nio.file.Path;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    56
import java.nio.file.Paths;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    57
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    58
import jdk.test.lib.Asserts;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    59
import jdk.test.lib.cds.CDSOptions;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    60
import jdk.test.lib.cds.CDSTestUtils;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    61
import jdk.test.lib.process.ProcessTools;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    62
import jdk.test.lib.process.OutputAnalyzer;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    63
51992
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    64
import jtreg.SkippedException;
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    65
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    66
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    67
public class ClassPathTests {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    68
    private static final String TEST_SRC = System.getProperty("test.src");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    69
    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    70
    private static final Path CLASSES_DIR = Paths.get("classes");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    71
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    72
    // the test module
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    73
    private static final String MAIN_CLASS = "jdk.test.Main";
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    74
    private static final String LIMITMODS_MAIN_CLASS = "jdk.test.LimitModsMain";
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    75
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    76
    // test classes to archive. These are both in UPGRADED_MODULES
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    77
    private static final String JIMAGE_CLASS      = "com/sun/tools/javac/Main";
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
    78
    private static final String APP_ARCHIVE_CLASS = "com/sun/tools/javac/MyMain";
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
    79
    private static final String PLATFORM_ARCHIVE_CLASS = "javax/annotation/processing/FilerException";
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    80
    private static final String[] ARCHIVE_CLASSES = {APP_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS, JIMAGE_CLASS};
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    81
    private static final int NUMBER_OF_TEST_CASES = 10;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    82
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    83
    private static String appJar;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    84
    private static String testArchiveName;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    85
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    86
51992
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    87
    public static void main(String[] args) throws Throwable {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    88
        ClassPathTests tests = new ClassPathTests();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    89
        tests.dumpArchive();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    90
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    91
        Method[] methods = tests.getClass().getDeclaredMethods();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    92
        int numOfTestMethodsRun = 0;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    93
        for (Method m : methods) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    94
            if (m.getName().startsWith("test")) {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    95
                System.out.println("About to run test method: " + m.getName());
51992
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    96
                try {
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    97
                    m.invoke(tests);
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    98
                } catch (InvocationTargetException ite) {
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
    99
                    Throwable throwable = ite.getCause();
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
   100
                    if (throwable instanceof SkippedException) {
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
   101
                        throw throwable;
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
   102
                    } else {
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
   103
                        throw ite;
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
   104
                    }
266a89a5d1af 8211287: ClassPathTests.java fails due to "Unable to map MiscData shared space at required address."
ccheung
parents: 51990
diff changeset
   105
                }
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   106
                numOfTestMethodsRun++;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   107
            }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   108
        }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   109
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   110
        Asserts.assertTrue((numOfTestMethodsRun == NUMBER_OF_TEST_CASES),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   111
            "Expected " + NUMBER_OF_TEST_CASES + " test methods to run, actual number is "
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   112
            + numOfTestMethodsRun);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   113
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   114
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   115
    private void dumpArchive() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   116
        // Create a jar file with all the classes related to this test.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   117
        JarBuilder.build( "classpathtests",
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   118
                          APP_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS, JIMAGE_CLASS,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   119
                          "jdk/test/Main");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   120
        appJar = TestCommon.getTestJar("classpathtests.jar");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   121
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   122
        // dump the archive with altnernate jdk.comiler and jdk.activation classes in the class list
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   123
        OutputAnalyzer output1  = TestCommon.dump(appJar, TestCommon.list(ARCHIVE_CLASSES));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   124
        TestCommon.checkDump(output1);
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   125
        // The PLATFORM_ARCHIVE_CLASS belongs to the java.compiler
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   126
        // module will be found from the module during dumping.
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   127
        // The JIMAGE_CLASS will be found from the jdk.compiler module during
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   128
        // dumping.
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   129
        // The APP_ARCHIVE_CLASS, which belongs to a package within the
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   130
        // jdk.compiler module, will not be found during dump time.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   131
        for (String archiveClass : ARCHIVE_CLASSES) {
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   132
            if (archiveClass.equals(APP_ARCHIVE_CLASS)) {
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   133
                output1.shouldContain("Preload Warning: Cannot find " + archiveClass);
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   134
            } else {
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   135
                output1.shouldNotContain("Preload Warning: Cannot find " + archiveClass);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   136
            }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   137
        }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   139
        testArchiveName = TestCommon.getCurrentArchiveName();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   140
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   141
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   142
    // #1: Archived classpath class in same package as jimage app class. With AppCDS.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   143
    // Should fail to load.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   144
    public void testAppClassWithAppCDS() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   145
        OutputAnalyzer output = TestCommon.exec(
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   146
            appJar, MAIN_CLASS,
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   147
            "Test #1", APP_ARCHIVE_CLASS, "false"); // last 3 args passed to test
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   148
        TestCommon.checkExec(output);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   149
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   150
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   151
    // #2: Archived classpath class in same package as jimage app class. Without AppCDS.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   152
    // Should fail to load.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   153
    public void testAppClassWithoutAppCDS() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   154
        CDSOptions opts = (new CDSOptions())
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   155
            .addPrefix("-cp", appJar)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   156
            .setArchiveName(testArchiveName)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   157
            .addSuffix(MAIN_CLASS, "Test #2", APP_ARCHIVE_CLASS, "false");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   158
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   159
        CDSTestUtils.runWithArchiveAndCheck(opts);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   160
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   161
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   162
    // #3: Archived classpath class in same package as jimage ext class. With AppCDS.
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   163
    // The class should be loaded from the module.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   164
    public void testExtClassWithAppCDS() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   165
        OutputAnalyzer output = TestCommon.exec(
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   166
            appJar, MAIN_CLASS,
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   167
            "Test #3", PLATFORM_ARCHIVE_CLASS, "true", "EXT"); // last 4 args passed to test
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   168
        TestCommon.checkExec(output);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   169
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   170
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   171
    // #4: Archived classpath class in same package as jimage ext class. Without AppCDS.
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   172
    // The class should be loaded from the module.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   173
    public void testExtClassWithoutAppCDS() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   174
        CDSOptions opts = (new CDSOptions())
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   175
            .addPrefix("-cp", appJar)
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   176
            .setArchiveName(testArchiveName)
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   177
            .addSuffix(MAIN_CLASS, "Test #4", PLATFORM_ARCHIVE_CLASS, "true", "EXT");
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   178
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   179
        CDSTestUtils.runWithArchiveAndCheck(opts);
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   180
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   181
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   182
    // #5: Archived classpath class in same package as jimage app class. With AppCDS.
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   183
    // Should load with CDS disabled because --limit-modules is used.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   184
    public void testAppClassWithLimitModsWithAppCDS() throws Exception {
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   185
        TestCommon.run("-cp", appJar,
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   186
                       "--limit-modules", "java.base",
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   187
                       MAIN_CLASS,
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   188
                       "Test #5", APP_ARCHIVE_CLASS, "true") // last 3 args passed to test
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   189
            .assertSilentlyDisabledCDS(out -> {
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   190
                out.shouldHaveExitValue(0);
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   191
            });
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   192
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   193
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   194
    // #6: Archived classpath class in same package as jimage app class. Without AppCDS.
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   195
    // Should load with CDS disabled because --limit-modules is used.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   196
    public void testAppClassWithLimitModsWithoutAppCDS() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   197
        CDSOptions opts = (new CDSOptions())
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   198
            .addPrefix("-cp", appJar, "--limit-modules", "java.base")
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   199
            .setArchiveName(testArchiveName)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   200
            .addSuffix(MAIN_CLASS, "Test #6", APP_ARCHIVE_CLASS, "true");
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   201
        CDSTestUtils.run(opts)
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   202
            .assertSilentlyDisabledCDS(out -> {
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   203
                out.shouldHaveExitValue(0);
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   204
            });
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   205
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   206
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   207
    // #7: Archived classpath class in same package as jimage ext class. With AppCDS.
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   208
    // Should load with CDS disabled because --limit-modules is used.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   209
    public void testExtClassWithLimitModsWithAppCDS() throws Exception {
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   210
        TestCommon.run("-cp", appJar,
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   211
                       "--limit-modules", "java.base",
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   212
                       MAIN_CLASS,
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   213
                       "Test #7", PLATFORM_ARCHIVE_CLASS, "true") // last 3 args passed to test
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   214
            .assertSilentlyDisabledCDS(out -> {
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   215
                out.shouldHaveExitValue(0);
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   216
            });
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   217
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   218
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   219
    // #8: Archived classpath class in same package as jimage ext class. Without AppCDS.
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   220
    // Should load with CDS disabled because --limit-modules is used.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   221
    public void testExtClassWithLimitModsWithoutAppCDS() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   222
        CDSOptions opts = (new CDSOptions())
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   223
            .addPrefix("-cp", appJar, "--limit-modules", "java.base")
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   224
            .setArchiveName(testArchiveName)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   225
            .addSuffix(MAIN_CLASS, "Test #8", PLATFORM_ARCHIVE_CLASS, "true");
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   226
        CDSTestUtils.run(opts)
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   227
            .assertSilentlyDisabledCDS(out -> {
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   228
                out.shouldHaveExitValue(0);
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   229
            });
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   230
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   231
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   232
    // #9: Archived classpath class with same name as jimage app class. With AppCDS.
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   233
    // Should load with CDS disabled because --limit-modules is used.
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   234
    public void testReplacingJImageClassWithAppCDS() throws Exception {
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   235
        TestCommon.run("-cp", appJar,
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   236
                       "--limit-modules", "java.base",
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   237
                       MAIN_CLASS,
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   238
                       "Test #9", JIMAGE_CLASS, "true") // last 3 args passed to test
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   239
            .assertSilentlyDisabledCDS(out -> {
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   240
                out.shouldHaveExitValue(0);
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   241
            });
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   242
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   243
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   244
    // #10: Archived classpath class with same name as jimage app class. Without AppCDS.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   245
    // Should load because --limit-modules is used. Note the archive will actually contain
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   246
    // the original jimage version of the class, but AppCDS should refuse to load it
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   247
    // since --limit-modules is used. This should result in the -cp version being used.
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   248
    public void testReplacingJImageClassWithoutAppCDS() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   249
        CDSOptions opts = (new CDSOptions())
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   250
            .addPrefix("-cp", appJar, "--limit-modules", "java.base")
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   251
            .setArchiveName(testArchiveName)
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   252
            .addSuffix(MAIN_CLASS, "Test #10", JIMAGE_CLASS, "true");
49894
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   253
        CDSTestUtils.run(opts)
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   254
            .assertSilentlyDisabledCDS(out -> {
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   255
                out.shouldHaveExitValue(0);
c830e94b5606 8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents: 48469
diff changeset
   256
            });
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   257
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   258
}