test/hotspot/jtreg/runtime/appcds/RelativePath.java
author ccheung
Fri, 28 Jun 2019 09:49:10 -0700
changeset 55524 b279ae9843b8
permissions -rw-r--r--
8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work Summary: Replaced os::file_name_strncmp() with os::same_files(). Reviewed-by: iklam, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55524
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     1
/*
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     4
 *
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     8
 *
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    13
 * accompanied this code).
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    14
 *
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    18
 *
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    21
 * questions.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    22
 *
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    23
 */
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    24
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    25
/*
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    26
 * @test
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    27
 * @summary Test relative paths specified in the -cp.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    28
 * @requires vm.cds
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    29
 * @library /test/lib
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    31
 *          java.management
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    32
 *          jdk.jartool/sun.tools.jar
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    33
 * @compile test-classes/Hello.java
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    34
 * @compile test-classes/HelloMore.java
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    35
 * @run driver RelativePath
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    36
 */
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    37
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    38
import java.io.File;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    39
import java.nio.file.Files;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    40
import java.nio.file.Path;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    41
import java.nio.file.Paths;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    42
import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    43
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    44
import java.util.Arrays;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    45
import jdk.test.lib.Platform;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    46
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    47
public class RelativePath {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    48
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    49
  private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    50
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    51
  public static void main(String[] args) throws Exception {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    52
    String appJar = JarBuilder.getOrCreateHelloJar();
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    53
    String appJar2 = JarBuilder.build("AppendClasspath_HelloMore", "HelloMore");
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    54
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    55
    // dump an archive with only the jar name in the -cp
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    56
    int idx = appJar.lastIndexOf(File.separator);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    57
    String jarName = appJar.substring(idx + 1);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    58
    String jarDir = appJar.substring(0, idx);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    59
    TestCommon.testDump(jarDir, jarName, TestCommon.list("Hello"));
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    60
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    61
    // copy the jar file to another dir. Specify the jar file without
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    62
    // a directory path.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    63
    Path srcPath = Paths.get(appJar);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    64
    Path destDir = Files.createTempDirectory(USER_DIR, "deploy");
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    65
    Path destPath = destDir.resolve(jarName);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    66
    Files.copy(srcPath, destPath, REPLACE_EXISTING, COPY_ATTRIBUTES);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    67
    TestCommon.runWithRelativePath(
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    68
        destDir.toString(),
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    69
        "-Xshare:on",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    70
        "-XX:SharedArchiveFile=" + TestCommon.getCurrentArchiveName(),
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    71
        "-cp", jarName + File.pathSeparator + appJar2,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    72
        "-Xlog:class+load=trace,class+path=info",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    73
        "HelloMore")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    74
        .assertNormalExit(output -> {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    75
                output.shouldContain("Hello source: shared objects file")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    76
                      .shouldHaveExitValue(0);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    77
            });
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    78
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    79
    // Long path test
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    80
    // Create a long directory path and copy the appJar there.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    81
    final int MAX_PATH = 260;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    82
    destDir = Paths.get(jarDir);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    83
    int subDirLen = MAX_PATH - jarDir.length() - 3;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    84
    if (subDirLen > 0) {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    85
        char[] chars = new char[subDirLen];
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    86
        Arrays.fill(chars, 'x');
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    87
        String subPath = new String(chars);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    88
        destDir = Paths.get(jarDir, subPath);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    89
    }
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    90
    File longDir = destDir.toFile();
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    91
    longDir.mkdir();
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    92
    String destJar = longDir.getPath() + File.separator + jarName;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    93
    Files.copy(Paths.get(appJar), Paths.get(destJar), REPLACE_EXISTING);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    94
    // Create an archive with the appJar in the long directory path.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    95
    TestCommon.testDump(destJar, TestCommon.list("Hello"));
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    96
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    97
    // Run with -cp containing the appJar and another jar appended.
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    98
    TestCommon.run(
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
    99
        "-cp", destJar + File.pathSeparator + appJar2,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   100
        "-Xlog:class+load=trace,class+path=info",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   101
        "HelloMore")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   102
        .assertNormalExit(output -> {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   103
                output.shouldContain("Hello source: shared objects file")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   104
                      .shouldHaveExitValue(0);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   105
            });
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   106
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   107
    // Dump an archive with a specified JAR file in -classpath
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   108
    TestCommon.testDump(appJar, TestCommon.list("Hello"));
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   109
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   110
    // compose a relative path to the hello.jar
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   111
    String newHello = TestCommon.composeRelPath(appJar);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   112
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   113
    // create a sym link to the original hello.jar
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   114
    File linkedHello = null;
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   115
    if (!Platform.isWindows()) {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   116
        linkedHello = TestCommon.createSymLink(appJar);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   117
    }
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   118
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   119
    // PASS:1) same appJar but referred to via a relative path
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   120
    TestCommon.run(
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   121
        "-cp", newHello + File.pathSeparator + appJar2,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   122
        "-Xlog:class+load=trace,class+path=info",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   123
        "HelloMore")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   124
      .assertNormalExit();
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   125
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   126
    // PASS:2) relative path starting with "."
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   127
    TestCommon.runWithRelativePath(
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   128
        jarDir,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   129
        "-Xshare:on",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   130
        "-XX:SharedArchiveFile=" + TestCommon.getCurrentArchiveName(),
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   131
        "-cp", "." + File.separator + jarName + File.pathSeparator + appJar2,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   132
        "-Xlog:class+load=trace,class+path=info",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   133
        "HelloMore")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   134
        .assertNormalExit(output -> {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   135
                output.shouldContain("Hello source: shared objects file")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   136
                      .shouldHaveExitValue(0);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   137
            });
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   138
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   139
    // PASS:3) relative path starting with ".."
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   140
    idx = jarDir.lastIndexOf(File.separator);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   141
    String jarSubDir = jarDir.substring(idx + 1);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   142
    TestCommon.runWithRelativePath(
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   143
        jarDir,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   144
        "-Xshare:on",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   145
        "-XX:SharedArchiveFile=" + TestCommon.getCurrentArchiveName(),
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   146
        "-cp", ".." + File.separator + jarSubDir + File.separator + jarName
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   147
               + File.pathSeparator + appJar2,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   148
        "-Xlog:class+load=trace,class+path=info",
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   149
        "HelloMore")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   150
        .assertNormalExit(output -> {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   151
                output.shouldContain("Hello source: shared objects file")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   152
                      .shouldHaveExitValue(0);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   153
            });
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   154
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   155
    // PASS:4) a jar linked to the original hello.jar
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   156
    if (!Platform.isWindows()) {
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   157
        TestCommon.run(
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   158
            "-cp", linkedHello.getPath() + File.pathSeparator + appJar2,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   159
            "HelloMore")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   160
          .assertNormalExit();
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   161
    }
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   162
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   163
    final String errorMessage1 = "Unable to use shared archive";
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   164
    final String errorMessage2 = "shared class paths mismatch";
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   165
    // FAIL: 1) runtime with classpath different from the one used in dump time
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   166
    // (runtime has an extra jar file prepended to the class path)
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   167
    TestCommon.run(
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   168
        "-cp", appJar2 + File.pathSeparator + newHello,
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   169
        "HelloMore")
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   170
        .assertAbnormalExit(errorMessage1, errorMessage2);
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   171
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   172
    }
b279ae9843b8 8211723: AppCDS: referring to a jar file in any way other than exactly how it was done during dumping doesn't work
ccheung
parents:
diff changeset
   173
}