Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java
41161 views
1
/*
2
* Copyright (c) 2006, 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 6409194
26
* @summary There should be no console output caused by the RMI
27
* implementation's logging, except as explicitly configured in the
28
* logging properties file, if none of the legacy sun.rmi.*.logLevel
29
* system properties are set.
30
*
31
* @author Peter Jones
32
*
33
* @library ../../../../../java/rmi/testlibrary
34
* @modules java.rmi/sun.rmi.registry
35
* java.rmi/sun.rmi.server
36
* java.rmi/sun.rmi.transport
37
* java.rmi/sun.rmi.transport.tcp
38
* @build JavaVM
39
* @run main/othervm NoConsoleOutput
40
*/
41
42
import java.io.ByteArrayOutputStream;
43
import java.io.File;
44
import java.rmi.Remote;
45
import java.rmi.RemoteException;
46
import java.rmi.server.UnicastRemoteObject;
47
48
public class NoConsoleOutput {
49
50
public static void main(String[] args) throws Exception {
51
System.err.println("\nRegression test for bug 6409194\n");
52
53
/*
54
* Execute a subprocess VM that does a bunch of RMI activity
55
* with a logging configuration file that does not specify a
56
* ConsoleHandler and with no legacy sun.rmi.*.logLevel system
57
* properties set.
58
*/
59
String loggingPropertiesFile =
60
System.getProperty("test.src", ".") +
61
File.separatorChar + "logging.properties";
62
ByteArrayOutputStream out = new ByteArrayOutputStream();
63
ByteArrayOutputStream err = new ByteArrayOutputStream();
64
65
// We instantiate a JavaVM that should not produce any console output
66
// on standard err streams, where RMI logging messages are sent to.
67
JavaVM vm = new JavaVM(
68
DoRMIStuff.class.getName(),
69
"--add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED"
70
+ " --add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED"
71
+ " --add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED"
72
+ " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
73
+ " -Djava.util.logging.config.file="
74
+ loggingPropertiesFile, "", out, err);
75
try {
76
vm.execute();
77
} finally {
78
vm.destroy();
79
}
80
81
/*
82
* Verify that the subprocess had no System.err output.
83
*/
84
String outString = out.toString();
85
String errString = err.toString();
86
87
System.err.println("-------- subprocess standard output: --------");
88
System.err.print(out);
89
System.err.println("-------- subprocess standard error: --------");
90
System.err.print(err);
91
System.err.println("---------------------------------------------");
92
93
if (errString.length() > 0) {
94
throw new Error("TEST FAILED: unexpected subprocess output");
95
}
96
97
System.err.println("TEST PASSED");
98
}
99
100
public static class DoRMIStuff {
101
private interface Foo extends Remote {
102
Object echo(Object obj) throws RemoteException;
103
}
104
private static class FooImpl implements Foo {
105
FooImpl() { }
106
public Object echo(Object obj) { return obj; }
107
}
108
public static void main(String[] args) throws Exception {
109
FooImpl fooimpl = new FooImpl();
110
Foo foostub = (Foo) UnicastRemoteObject.exportObject(fooimpl, 0);
111
FooImpl fooimpl2 = new FooImpl();
112
UnicastRemoteObject.exportObject(fooimpl2, 0);
113
foostub.echo(fooimpl2);
114
UnicastRemoteObject.unexportObject(fooimpl, true);
115
UnicastRemoteObject.unexportObject(fooimpl2, true);
116
}
117
}
118
}
119
120