test/hotspot/jtreg/runtime/appcds/BootClassPathMismatch.java
author iklam
Tue, 02 Oct 2018 14:32:33 -0700
changeset 51990 6003e034cdd8
parent 50199 83d8b3a25f25
child 54927 1512d88b24c6
permissions -rw-r--r--
8209946: [TESTBUG] CDS tests should use "@run driver" Reviewed-by: ccheung, jiangli, mseledtsov
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
/*
48979
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
     2
 * Copyright (c) 2014, 2018, 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
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    27
 * @summary bootclasspath mismatch test.
48469
7312ae4465d6 8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents: 48171
diff changeset
    28
 * @requires vm.cds
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    29
 * @library /test/lib
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    31
 *          java.management
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    32
 *          jdk.jartool/sun.tools.jar
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    33
 * @compile test-classes/Hello.java
51990
6003e034cdd8 8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents: 50199
diff changeset
    34
 * @run driver BootClassPathMismatch
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    35
 */
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    36
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    37
import jdk.test.lib.cds.CDSOptions;
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    38
import jdk.test.lib.cds.CDSTestUtils;
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    39
import jdk.test.lib.process.OutputAnalyzer;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    40
import java.io.File;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    41
import java.nio.file.Files;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    42
import java.nio.file.FileAlreadyExistsException;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    43
import java.nio.file.StandardCopyOption;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    44
import java.nio.file.Paths;
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    45
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    46
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    47
public class BootClassPathMismatch {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    48
    private static final String mismatchMessage = "shared class paths mismatch";
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    49
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    50
    public static void main(String[] args) throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    51
        JarBuilder.getOrCreateHelloJar();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    52
        copyHelloToNewDir();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    53
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    54
        BootClassPathMismatch test = new BootClassPathMismatch();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    55
        test.testBootClassPathMismatch();
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    56
        test.testBootClassPathMismatchWithAppClass();
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    57
        test.testBootClassPathMismatchWithBadPath();
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    58
        test.testBootClassPathMatchWithAppend();
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    59
        test.testBootClassPathMatch();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    60
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    61
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    62
    /* Archive contains boot classes only, with Hello class on -Xbootclasspath/a path.
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    63
     *
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    64
     * Error should be detected if:
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    65
     * dump time: -Xbootclasspath/a:${testdir}/hello.jar
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    66
     * run-time : -Xbootclasspath/a:${testdir}/newdir/hello.jar
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    67
     *
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    68
     * or
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    69
     * dump time: -Xbootclasspath/a:${testdir}/newdir/hello.jar
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    70
     * run-time : -Xbootclasspath/a:${testdir}/hello.jar
48138
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
    public void testBootClassPathMismatch() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    73
        String appJar = JarBuilder.getOrCreateHelloJar();
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    74
        String appClasses[] = {"Hello"};
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    75
        String testDir = TestCommon.getTestDir("newdir");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    76
        String otherJar = testDir + File.separator + "hello.jar";
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    77
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    78
        TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar);
48979
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
    79
        TestCommon.run(
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    80
                "-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello")
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    81
            .assertAbnormalExit(mismatchMessage);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    82
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    83
        TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + otherJar);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    84
        TestCommon.run(
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    85
                "-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello")
48979
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
    86
            .assertAbnormalExit(mismatchMessage);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    87
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
    88
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    89
    /* Archive contains boot classes only.
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    90
     *
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    91
     * Error should be detected if:
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    92
     * dump time: -Xbootclasspath/a:${testdir}/newdir/hello.jar
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    93
     * run-time : -Xbootclasspath/a:${testdir}/newdir/hello.jar1
48171
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48138
diff changeset
    94
     */
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    95
    public void testBootClassPathMismatchWithBadPath() throws Exception {
48171
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48138
diff changeset
    96
        String appClasses[] = {"Hello"};
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    97
        String testDir = TestCommon.getTestDir("newdir");
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    98
        String appJar = testDir + File.separator + "hello.jar";
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
    99
        String otherJar = testDir + File.separator + "hello.jar1";
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   100
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   101
        TestCommon.dump(appJar, appClasses, "-Xbootclasspath/a:" + appJar);
48979
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
   102
        TestCommon.run(
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   103
                "-cp", appJar, "-Xbootclasspath/a:" + otherJar, "Hello")
48979
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
   104
            .assertAbnormalExit(mismatchMessage);
48171
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48138
diff changeset
   105
    }
7ad2d33a0f05 8174101: Bootclasspath append should not invalidate CDS archive
ccheung
parents: 48138
diff changeset
   106
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   107
    /* Archive contains boot classes only, with Hello loaded from -Xbootclasspath/a at dump time.
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   108
     *
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   109
     * No error if:
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   110
     * dump time: -Xbootclasspath/a:${testdir}/hello.jar
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   111
     * run-time : -Xbootclasspath/a:${testdir}/hello.jar
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   112
     */
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   113
    public void testBootClassPathMatch() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   114
        String appJar = TestCommon.getTestJar("hello.jar");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   115
        String appClasses[] = {"Hello"};
48979
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
   116
        TestCommon.dump(
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   117
            appJar, appClasses, "-Xbootclasspath/a:" + appJar);
48979
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
   118
        TestCommon.run(
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
   119
                "-cp", appJar, "-verbose:class",
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
   120
                "-Xbootclasspath/a:" + appJar, "Hello")
514c73a1955b 8179249: Improve process output analysis in CDS tests
iklam
parents: 48469
diff changeset
   121
            .assertNormalExit("[class,load] Hello source: shared objects file");
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   122
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   123
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   124
    /* Archive contains boot classes only, runtime add -Xbootclasspath/a path.
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   125
     *
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   126
     * No error:
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   127
     * dump time: No -Xbootclasspath/a
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   128
     * run-time : -Xbootclasspath/a:${testdir}/hello.jar
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   129
     */
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   130
    public void testBootClassPathMatchWithAppend() throws Exception {
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   131
      CDSOptions opts = new CDSOptions().setUseVersion(false);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   132
      OutputAnalyzer out = CDSTestUtils.createArchive(opts);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   133
      CDSTestUtils.checkDump(out);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   134
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   135
      String appJar = JarBuilder.getOrCreateHelloJar();
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   136
      opts.addPrefix("-Xbootclasspath/a:" + appJar, "-showversion").addSuffix("Hello");
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   137
      CDSTestUtils.runWithArchiveAndCheck(opts);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   138
    }
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   139
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   140
    /* Archive contains app classes, with Hello on -cp path at dump time.
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   141
     *
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   142
     * Error should be detected if:
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   143
     * dump time: <no bootclasspath specified>
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   144
     * run-time : -Xbootclasspath/a:${testdir}/hello.jar
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   145
     */
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   146
    public void testBootClassPathMismatchWithAppClass() throws Exception {
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   147
        String appJar = JarBuilder.getOrCreateHelloJar();
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   148
        String appClasses[] = {"Hello"};
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   149
        TestCommon.dump(appJar, appClasses);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   150
        TestCommon.run(
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   151
                "-cp", appJar, "-Xbootclasspath/a:" + appJar, "Hello")
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   152
            .assertAbnormalExit(mismatchMessage);
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   153
    }
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   154
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   155
    private static void copyHelloToNewDir() throws Exception {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   156
        String classDir = System.getProperty("test.classes");
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   157
        String dstDir = classDir + File.separator + "newdir";
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   158
        try {
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   159
            Files.createDirectory(Paths.get(dstDir));
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   160
        } catch (FileAlreadyExistsException e) { }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   161
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   162
        // copy as hello.jar
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   163
        Files.copy(Paths.get(classDir, "hello.jar"),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   164
            Paths.get(dstDir, "hello.jar"),
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   165
            StandardCopyOption.REPLACE_EXISTING);
50199
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   166
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   167
        // copy as hello.jar1
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   168
        Files.copy(Paths.get(classDir, "hello.jar"),
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   169
            Paths.get(dstDir, "hello.jar1"),
83d8b3a25f25 8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents: 48979
diff changeset
   170
            StandardCopyOption.REPLACE_EXISTING);
48138
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   171
    }
78b2ecdd3c4b 8188791: Move AppCDS from closed repo to open repo
iklam
parents:
diff changeset
   172
}