author | iklam |
Mon, 04 Dec 2017 08:59:47 -0800 | |
changeset 48469 | 7312ae4465d6 |
parent 48138 | 78b2ecdd3c4b |
child 48979 | 514c73a1955b |
permissions | -rw-r--r-- |
48138 | 1 |
/* |
2 |
* Copyright (c) 2016, 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 |
|
48469
7312ae4465d6
8193672: [test] Enhance vm.cds property to check for all conditions required to run CDS tests
iklam
parents:
48138
diff
changeset
|
27 |
* @requires vm.cds |
48138 | 28 |
* @summary a patched class found in --patch-module should be used at runtime |
29 |
* @library ../.. |
|
30 |
* @library /test/hotspot/jtreg/testlibrary |
|
31 |
* @library /test/lib |
|
32 |
* @modules java.base/jdk.internal.misc |
|
33 |
* jdk.jartool/sun.tools.jar |
|
34 |
* @build PatchMain |
|
35 |
* @run main TwoJars |
|
36 |
*/ |
|
37 |
||
38 |
import java.io.File; |
|
39 |
import jdk.test.lib.compiler.InMemoryJavaCompiler; |
|
40 |
import jdk.test.lib.process.OutputAnalyzer; |
|
41 |
||
42 |
public class TwoJars { |
|
43 |
private static String moduleJar; |
|
44 |
private static String moduleJar2; |
|
45 |
||
46 |
public static void main(String args[]) throws Throwable { |
|
47 |
||
48 |
// Create a class file in the module java.naming. This class file |
|
49 |
// will be put in the javanaming.jar file. |
|
50 |
String source = "package javax.naming.spi; " + |
|
51 |
"public class NamingManager { " + |
|
52 |
" static { " + |
|
53 |
" System.out.println(\"I pass!\"); " + |
|
54 |
" } " + |
|
55 |
"}"; |
|
56 |
||
57 |
// Create a class file in the module java.naming. This class file |
|
58 |
// will be put in the javanaming2.jar file. |
|
59 |
String source2 = "package javax.naming.spi; " + |
|
60 |
"public class DirectoryManager { " + |
|
61 |
" static { " + |
|
62 |
" System.out.println(\"I fail!\"); " + |
|
63 |
" } " + |
|
64 |
"}"; |
|
65 |
||
66 |
ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager", |
|
67 |
InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "--patch-module=java.naming"), |
|
68 |
System.getProperty("test.classes")); |
|
69 |
||
70 |
// Build the jar file that will be used for the module "java.naming". |
|
71 |
JarBuilder.build("javanaming", "javax/naming/spi/NamingManager"); |
|
72 |
moduleJar = TestCommon.getTestJar("javanaming.jar"); |
|
73 |
||
74 |
ClassFileInstaller.writeClassToDisk("javax/naming/spi/DirectoryManager", |
|
75 |
InMemoryJavaCompiler.compile("javax.naming.spi.DirectoryManager", source2, "--patch-module=java.naming"), |
|
76 |
System.getProperty("test.classes")); |
|
77 |
||
78 |
// Build the jar file that will be used for the module "java.naming". |
|
79 |
JarBuilder.build("javanaming2", "javax/naming/spi/DirectoryManager"); |
|
80 |
moduleJar2 = TestCommon.getTestJar("javanaming2.jar"); |
|
81 |
||
82 |
System.out.println("Test dumping with --patch-module"); |
|
83 |
OutputAnalyzer output = |
|
84 |
TestCommon.dump(null, |
|
85 |
TestCommon.list("javax/naming/spi/NamingManager"), |
|
86 |
"--patch-module=java.naming=" + moduleJar2 + File.pathSeparator + moduleJar, |
|
87 |
"-Xlog:class+load", |
|
88 |
"-Xlog:class+path=info", |
|
89 |
"PatchMain", "javax.naming.spi.NamingManager"); |
|
90 |
TestCommon.checkDump(output, "Loading classes to share"); |
|
91 |
||
92 |
output = TestCommon.execCommon( |
|
93 |
"-XX:+UnlockDiagnosticVMOptions", |
|
94 |
"--patch-module=java.naming=" + moduleJar2 + File.pathSeparator + moduleJar, |
|
95 |
"-Xlog:class+load", |
|
96 |
"-Xlog:class+path=info", |
|
97 |
"PatchMain", "javax.naming.spi.NamingManager"); |
|
98 |
TestCommon.checkExec(output, "I pass"); |
|
99 |
} |
|
100 |
} |