48138
|
1 |
/*
|
|
2 |
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
* @test
|
|
27 |
* @summary At run time, it is OK to append new elements to the classpath that was used at dump time.
|
|
28 |
* AppCDS does not support uncompressed oops
|
|
29 |
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
|
|
30 |
* @library /test/lib
|
|
31 |
* @modules java.base/jdk.internal.misc
|
|
32 |
* java.management
|
|
33 |
* jdk.jartool/sun.tools.jar
|
|
34 |
* @compile test-classes/Hello.java
|
|
35 |
* @compile test-classes/HelloMore.java
|
|
36 |
* @run main AppendClasspath
|
|
37 |
*/
|
|
38 |
|
|
39 |
import java.io.File;
|
|
40 |
import jdk.test.lib.process.OutputAnalyzer;
|
|
41 |
|
|
42 |
public class AppendClasspath {
|
|
43 |
|
|
44 |
public static void main(String[] args) throws Exception {
|
|
45 |
String appJar = JarBuilder.getOrCreateHelloJar();
|
|
46 |
String appJar2 = JarBuilder.build("AppendClasspath_HelloMore", "HelloMore");
|
|
47 |
|
|
48 |
// Dump an archive with a specified JAR file in -classpath
|
|
49 |
TestCommon.testDump(appJar, TestCommon.list("Hello"));
|
|
50 |
|
|
51 |
// PASS: 1) runtime with classpath containing the one used in dump time
|
|
52 |
OutputAnalyzer output = TestCommon.execCommon(
|
|
53 |
"-cp", appJar + File.pathSeparator + appJar2,
|
|
54 |
"HelloMore");
|
|
55 |
TestCommon.checkExec(output);
|
|
56 |
|
|
57 |
final String errorMessage1 = "Unable to use shared archive";
|
|
58 |
final String errorMessage2 = "shared class paths mismatch";
|
|
59 |
// FAIL: 2) runtime with classpath different from the one used in dump time
|
|
60 |
// (runtime has an extra jar file prepended to the class path)
|
|
61 |
output = TestCommon.execCommon(
|
|
62 |
"-cp", appJar2 + File.pathSeparator + appJar,
|
|
63 |
"HelloMore");
|
|
64 |
output.shouldContain(errorMessage1);
|
|
65 |
output.shouldContain(errorMessage2);
|
|
66 |
output.shouldHaveExitValue(1);
|
|
67 |
|
|
68 |
// FAIL: 3) runtime with classpath part of the one used in dump time
|
|
69 |
TestCommon.testDump(appJar + File.pathSeparator + appJar2,
|
|
70 |
TestCommon.list("Hello"));
|
|
71 |
output = TestCommon.execCommon(
|
|
72 |
"-cp", appJar2,
|
|
73 |
"Hello");
|
|
74 |
output.shouldContain(errorMessage1);
|
|
75 |
output.shouldContain(errorMessage2);
|
|
76 |
output.shouldHaveExitValue(1);
|
|
77 |
|
|
78 |
// FAIL: 4) runtime with same set of jar files in the classpath but
|
|
79 |
// with different order
|
|
80 |
output = TestCommon.execCommon(
|
|
81 |
"-cp", appJar2 + File.pathSeparator + appJar,
|
|
82 |
"HelloMore");
|
|
83 |
output.shouldContain(errorMessage1);
|
|
84 |
output.shouldContain(errorMessage2);
|
|
85 |
output.shouldHaveExitValue(1);
|
|
86 |
}
|
|
87 |
}
|