Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/rmi/registry/readTest/CodebaseTest.java
41154 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
/* @test
25
* @bug 7102369 7094468 7100592
26
* @modules java.rmi/sun.rmi.registry
27
* java.rmi/sun.rmi.server
28
* java.rmi/sun.rmi.transport
29
* java.rmi/sun.rmi.transport.tcp
30
* @library ../../testlibrary
31
* @build TestLibrary RMIRegistryRunner RegistryVM JavaVM testPkg.* RegistryLookup
32
* @summary remove java.rmi.server.codebase property parsing from registyimpl
33
* @run main/othervm CodebaseTest
34
*/
35
36
import java.io.File;
37
import java.nio.file.Files;
38
import java.nio.file.StandardCopyOption;
39
import java.rmi.registry.Registry;
40
import java.rmi.registry.LocateRegistry;
41
import java.rmi.RemoteException;
42
import java.rmi.server.UnicastRemoteObject;
43
44
public class CodebaseTest {
45
46
public static void main(String args[]) throws Exception {
47
RegistryVM rmiregistry = null;
48
JavaVM client = null;
49
try {
50
File src = new File(System.getProperty("test.classes", "."), "testPkg");
51
File dest = new File(System.getProperty("user.dir", "."), "testPkg");
52
Files.move(src.toPath(), dest.toPath(),
53
StandardCopyOption.REPLACE_EXISTING);
54
55
File rmiregistryDir =
56
new File(System.getProperty("user.dir", "."), "rmi_tmp");
57
rmiregistryDir.mkdirs();
58
rmiregistry = RegistryVM.createRegistryVMWithRunner(
59
"RMIRegistryRunner",
60
" -Djava.rmi.server.useCodebaseOnly=false -Djava.security.manager=allow"
61
+ " -Duser.dir=" + rmiregistryDir.getAbsolutePath());
62
rmiregistry.start();
63
int port = rmiregistry.getPort();
64
65
File srcReadTest = new File(System.getProperty("test.classes", "."),
66
"RegistryLookup.class");
67
File destReadTest = new File(System.getProperty("user.dir", "."),
68
"RegistryLookup.class");
69
Files.move(srcReadTest.toPath(), destReadTest.toPath(),
70
StandardCopyOption.REPLACE_EXISTING);
71
72
File codebase = new File(System.getProperty("user.dir", "."));
73
client = new JavaVM("RegistryLookup",
74
" -Djava.rmi.server.codebase=" + codebase.toURI().toURL()
75
+ " -cp ." + File.pathSeparator + System.getProperty("test.class.path"),
76
Integer.toString(port));
77
int exit = client.execute();
78
if (exit == RegistryLookup.EXIT_FAIL) {
79
throw new RuntimeException("Test Fails");
80
}
81
} finally {
82
if (rmiregistry != null) {
83
rmiregistry.cleanup();
84
}
85
if (client != null) {
86
client.cleanup();
87
}
88
}
89
}
90
}
91
92