Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java
41161 views
1
/*
2
* Copyright (c) 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
* @test
26
* @bug 4087295 4785472
27
* @library /test/lib
28
* @build jdk.test.lib.compiler.CompilerUtils
29
* jdk.test.lib.Utils
30
* jdk.test.lib.Asserts
31
* jdk.test.lib.JDKToolFinder
32
* jdk.test.lib.JDKToolLauncher
33
* jdk.test.lib.Platform
34
* jdk.test.lib.process.*
35
* @build RenamePackageTest
36
* @run main RenamePackageTest
37
* @summary Enable resolveClass() to accommodate package renaming.
38
* This fix enables one to implement a resolveClass method that maps a
39
* Serialiazable class within a serialization stream to the same class
40
* in a different package within the JVM runtime. See run shell script
41
* for instructions on how to run this test.
42
*/
43
44
import java.io.File;
45
import java.nio.file.Path;
46
import java.nio.file.Paths;
47
48
import jdk.test.lib.compiler.CompilerUtils;
49
import jdk.test.lib.process.ProcessTools;
50
51
public class RenamePackageTest {
52
public static void main(String args[]) throws Exception {
53
setup();
54
55
runTestSerialDriver();
56
runInstallSerialDriver();
57
58
runInstallSerialDriver();
59
runTestSerialDriver();
60
}
61
62
private static final Path SHARE = Paths.get(System.getProperty("test.classes"), "share");
63
private static final Path OCLASSES = Paths.get(System.getProperty("test.classes"), "oclasses");
64
private static final Path NCLASSES = Paths.get(System.getProperty("test.classes"), "nclasses");
65
66
private static void setup() throws Exception {
67
68
boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "extension"),
69
SHARE);
70
assertTrue(b);
71
b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "test"),
72
OCLASSES,
73
"-classpath",
74
SHARE.toString());
75
assertTrue(b);
76
b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "install"),
77
NCLASSES,
78
"-classpath",
79
SHARE.toString());
80
assertTrue(b);
81
}
82
83
private static void runTestSerialDriver() throws Exception {
84
ProcessBuilder pb = ProcessTools.createTestJvm(
85
"-classpath",
86
SHARE.toString()
87
+ File.pathSeparator
88
+ OCLASSES.toString(),
89
"test.SerialDriver", "-s");
90
Process p = ProcessTools.startProcess("test SerialDriver", pb);
91
p.waitFor();
92
assertTrue(p.exitValue() == 0);
93
}
94
95
private static void runInstallSerialDriver() throws Exception {
96
ProcessBuilder pb = ProcessTools.createTestJvm(
97
"-classpath",
98
SHARE.toString()
99
+ File.pathSeparator
100
+ NCLASSES.toString(),
101
"install.SerialDriver", "-d");
102
Process p = ProcessTools.startProcess("install SerialDriver", pb);
103
p.waitFor();
104
assertTrue(p.exitValue() == 0);
105
}
106
107
private static void assertTrue(boolean b) {
108
if (!b) {
109
throw new RuntimeException("expected true, get false");
110
}
111
}
112
}
113
114