author | ccheung |
Fri, 11 Jan 2019 14:05:57 -0800 | |
changeset 53261 | b7dca420fa0c |
parent 51990 | 6003e034cdd8 |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
53261
b7dca420fa0c
8216184: CDS/appCDS tests failed on Windows due to long path to a classlist file
ccheung
parents:
51990
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
48138 | 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 Ensure that classes found in jimage takes precedence over classes found in -Xbootclasspath/a. |
|
48469
7312ae4465d6
8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents:
48138
diff
changeset
|
28 |
* @requires vm.cds |
48138 | 29 |
* @library /test/lib /test/hotspot/jtreg/runtime/appcds |
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
30 |
* @modules java.compiler |
48138 | 31 |
* jdk.jartool/sun.tools.jar |
32 |
* @compile ../../test-classes/DummyClassHelper.java |
|
33 |
* @compile ../../test-classes/java/net/HttpCookie.jasm |
|
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
34 |
* @compile ../../../SharedArchiveFile/javax/annotation/processing/FilerException.jasm |
48138 | 35 |
* @build sun.hotspot.WhiteBox |
48791
6e079ff6c83c
8186635: ClassFileInstaller should be run as a driver
iignatyev
parents:
48469
diff
changeset
|
36 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
49894
diff
changeset
|
37 |
* @run driver DummyClassesInBootClassPath |
48138 | 38 |
*/ |
39 |
||
40 |
import java.io.File; |
|
41 |
import java.util.List; |
|
42 |
import java.util.ArrayList; |
|
43 |
import jdk.test.lib.process.OutputAnalyzer; |
|
44 |
||
45 |
public class DummyClassesInBootClassPath { |
|
46 |
private static final String METHOD_NAME = "thisClassIsDummy()"; |
|
47 |
||
48832
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
48 |
static void checkOutput(OutputAnalyzer output, String[] classNames) throws Exception { |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
49 |
for (int i = 0; i < classNames.length; i++) { |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
50 |
String cn = classNames[i].replace('/', '.'); |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
51 |
TestCommon.checkExec(output, |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
52 |
"java.lang.NoSuchMethodException: " + cn + "." + |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
53 |
METHOD_NAME); |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
54 |
output.shouldNotContain(cn + ".class should be in shared space."); |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
55 |
} |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
56 |
} |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
57 |
|
48138 | 58 |
public static void main(String[] args) throws Exception { |
59 |
String classNames[] = { "java/net/HttpCookie", |
|
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
60 |
"javax/annotation/processing/FilerException"}; |
48138 | 61 |
JarBuilder.build("dummyClasses", classNames[0], classNames[1]); |
62 |
||
63 |
String appJar = TestCommon.getTestJar("dummyClasses.jar"); |
|
64 |
OutputAnalyzer dumpOutput = TestCommon.dump( |
|
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
65 |
appJar, classNames, "-Xbootclasspath/a:" + appJar); |
53261
b7dca420fa0c
8216184: CDS/appCDS tests failed on Windows due to long path to a classlist file
ccheung
parents:
51990
diff
changeset
|
66 |
TestCommon.checkDump(dumpOutput); |
b7dca420fa0c
8216184: CDS/appCDS tests failed on Windows due to long path to a classlist file
ccheung
parents:
51990
diff
changeset
|
67 |
|
48138 | 68 |
List<String> argsList = new ArrayList<String>(); |
69 |
for (int i = 0; i < classNames.length; i++) { |
|
70 |
argsList.add(classNames[i].replace('/', '.')); |
|
71 |
} |
|
72 |
String[] arguments = new String[argsList.size()]; |
|
73 |
arguments = argsList.toArray(arguments); |
|
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
74 |
TestCommon.run( |
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
75 |
"-Xbootclasspath/a:" + appJar, |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48832
diff
changeset
|
76 |
"DummyClassHelper", arguments[0], arguments[1]) |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48832
diff
changeset
|
77 |
.assertNormalExit(output -> checkOutput(output, classNames)); |
48138 | 78 |
|
79 |
JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox"); |
|
80 |
String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar"); |
|
81 |
String bootClassPath = "-Xbootclasspath/a:" + appJar + |
|
82 |
File.pathSeparator + whiteBoxJar; |
|
48832
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
83 |
dumpOutput = TestCommon.dump( |
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
84 |
appJar, classNames, bootClassPath); |
48138 | 85 |
argsList.add("testWithWhiteBox"); |
86 |
arguments = new String[argsList.size()]; |
|
87 |
arguments = argsList.toArray(arguments); |
|
88 |
String[] opts = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
|
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
89 |
bootClassPath, "-Xlog:class+path=trace", |
48832
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
90 |
"DummyClassHelper", arguments[0], arguments[1], arguments[2]}; |
49894
c830e94b5606
8197959: [TESTBUG] Some (App)CDS tests require modification due to the removal of the Java EE and CORBA modules
ccheung
parents:
48979
diff
changeset
|
91 |
TestCommon.run(opts) |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48832
diff
changeset
|
92 |
.assertNormalExit(output -> checkOutput(output, classNames)); |
48138 | 93 |
} |
94 |
} |
|
95 |