author | iklam |
Fri, 09 Aug 2019 13:13:36 -0700 | |
changeset 57705 | 7cf02b2c1455 |
parent 57567 | b000362a89a0 |
child 58679 | 9c3209ff7550 |
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 |
57567
b000362a89a0
8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents:
53261
diff
changeset
|
29 |
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds |
57705
7cf02b2c1455
8229267: [TESTBUG] Remove unnecessary @modules dependencies in CDS tests
iklam
parents:
57567
diff
changeset
|
30 |
* @modules jdk.jartool/sun.tools.jar |
48138 | 31 |
* @compile ../../test-classes/DummyClassHelper.java |
32 |
* @compile ../../test-classes/java/net/HttpCookie.jasm |
|
57567
b000362a89a0
8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents:
53261
diff
changeset
|
33 |
* @compile ../../../javax/annotation/processing/FilerException.jasm |
48138 | 34 |
* @build sun.hotspot.WhiteBox |
48791
6e079ff6c83c
8186635: ClassFileInstaller should be run as a driver
iignatyev
parents:
48469
diff
changeset
|
35 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
49894
diff
changeset
|
36 |
* @run driver DummyClassesInBootClassPath |
48138 | 37 |
*/ |
38 |
||
39 |
import java.io.File; |
|
40 |
import java.util.List; |
|
41 |
import java.util.ArrayList; |
|
42 |
import jdk.test.lib.process.OutputAnalyzer; |
|
43 |
||
44 |
public class DummyClassesInBootClassPath { |
|
45 |
private static final String METHOD_NAME = "thisClassIsDummy()"; |
|
46 |
||
48832
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
47 |
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
|
48 |
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
|
49 |
String cn = classNames[i].replace('/', '.'); |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
50 |
TestCommon.checkExec(output, |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
51 |
"java.lang.NoSuchMethodException: " + cn + "." + |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
52 |
METHOD_NAME); |
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
53 |
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
|
54 |
} |
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 |
|
48138 | 57 |
public static void main(String[] args) throws Exception { |
58 |
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
|
59 |
"javax/annotation/processing/FilerException"}; |
48138 | 60 |
JarBuilder.build("dummyClasses", classNames[0], classNames[1]); |
61 |
||
62 |
String appJar = TestCommon.getTestJar("dummyClasses.jar"); |
|
63 |
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
|
64 |
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
|
65 |
TestCommon.checkDump(dumpOutput); |
b7dca420fa0c
8216184: CDS/appCDS tests failed on Windows due to long path to a classlist file
ccheung
parents:
51990
diff
changeset
|
66 |
|
48138 | 67 |
List<String> argsList = new ArrayList<String>(); |
68 |
for (int i = 0; i < classNames.length; i++) { |
|
69 |
argsList.add(classNames[i].replace('/', '.')); |
|
70 |
} |
|
71 |
String[] arguments = new String[argsList.size()]; |
|
72 |
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
|
73 |
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
|
74 |
"-Xbootclasspath/a:" + appJar, |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48832
diff
changeset
|
75 |
"DummyClassHelper", arguments[0], arguments[1]) |
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48832
diff
changeset
|
76 |
.assertNormalExit(output -> checkOutput(output, classNames)); |
48138 | 77 |
|
78 |
JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox"); |
|
79 |
String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar"); |
|
80 |
String bootClassPath = "-Xbootclasspath/a:" + appJar + |
|
81 |
File.pathSeparator + whiteBoxJar; |
|
48832
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
82 |
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
|
83 |
appJar, classNames, bootClassPath); |
48138 | 84 |
argsList.add("testWithWhiteBox"); |
85 |
arguments = new String[argsList.size()]; |
|
86 |
arguments = argsList.toArray(arguments); |
|
87 |
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
|
88 |
bootClassPath, "-Xlog:class+path=trace", |
48832
f1e8ddd6fdc4
8196124: [testbug] runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java passes despite of error
ccheung
parents:
48791
diff
changeset
|
89 |
"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
|
90 |
TestCommon.run(opts) |
48979
514c73a1955b
8179249: Improve process output analysis in CDS tests
iklam
parents:
48832
diff
changeset
|
91 |
.assertNormalExit(output -> checkOutput(output, classNames)); |
48138 | 92 |
} |
93 |
} |
|
94 |