author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57705 | 7cf02b2c1455 |
permissions | -rw-r--r-- |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
1 |
/* |
53636
962ed57b29c9
8218029: [TESTBUG] Use -Djava.class.path= to specify empty -cp in CDS tests
iklam
parents:
52218
diff
changeset
|
2 |
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
4 |
* |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
8 |
* |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
13 |
* accompanied this code). |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
14 |
* |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
18 |
* |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
21 |
* questions. |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
22 |
*/ |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
23 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
24 |
/* |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
25 |
* @test NonBootLoaderClasses |
49931 | 26 |
* @summary Test to ensure platform and app classes are archived when specified in classlist |
48469
7312ae4465d6
8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents:
47216
diff
changeset
|
27 |
* @requires vm.cds |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
28 |
* @library /test/lib |
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
51411
diff
changeset
|
29 |
* @run driver NonBootLoaderClasses |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
30 |
*/ |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
31 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
32 |
import jdk.test.lib.cds.CDSOptions; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
33 |
import jdk.test.lib.cds.CDSTestUtils; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
34 |
import jdk.test.lib.process.OutputAnalyzer; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
35 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
36 |
public class NonBootLoaderClasses { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
37 |
public static void main(String[] args) throws Exception { |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
38 |
final String PLATFORM_CLASS = "jdk/dynalink/DynamicLinker"; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
39 |
final String APP_CLASS = "com/sun/tools/javac/Main"; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
40 |
String[] classes = {PLATFORM_CLASS, APP_CLASS}; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
41 |
String classList = |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
42 |
CDSTestUtils.makeClassList(classes).getPath(); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
43 |
String archiveName = "NonBootLoaderClasses.jsa"; |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
44 |
CDSOptions opts = (new CDSOptions()) |
53636
962ed57b29c9
8218029: [TESTBUG] Use -Djava.class.path= to specify empty -cp in CDS tests
iklam
parents:
52218
diff
changeset
|
45 |
.addPrefix("-XX:ExtraSharedClassListFile=" + classList, "-Djava.class.path=") |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
46 |
.setArchiveName(archiveName); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
47 |
CDSTestUtils.createArchiveAndCheck(opts); |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
48 |
|
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
49 |
// Print the shared dictionary and inspect the output |
52218
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
50 |
opts = (new CDSOptions()) |
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
51 |
.setUseVersion(false) |
53636
962ed57b29c9
8218029: [TESTBUG] Use -Djava.class.path= to specify empty -cp in CDS tests
iklam
parents:
52218
diff
changeset
|
52 |
.addSuffix("-Djava.class.path=", |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
53 |
"-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName, |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
54 |
"-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary"); |
52218
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
55 |
CDSTestUtils.run(opts) |
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
56 |
.assertNormalExit(output -> { |
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
57 |
output.shouldContain("archive is valid"); |
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
58 |
output.shouldContain(PLATFORM_CLASS.replace('/', '.')); |
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
59 |
output.shouldContain(APP_CLASS.replace('/', '.')); |
111ba072921b
8210990: [TESTBUG] Some CDS tests don't respect JVM variant being tested
ccheung
parents:
51990
diff
changeset
|
60 |
}); |
47103
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
61 |
} |
a993ec29ec75
8186842: Use Java class loaders for creating the CDS archive
ccheung
parents:
diff
changeset
|
62 |
} |