Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java
38867 views
1
/*
2
* Copyright (c) 2006, 2013, 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
* @build TestLibrary JavaVM
35
* @run main/othervm NoConsoleOutput
36
*/
37
38
import java.io.ByteArrayOutputStream;
39
import java.io.File;
40
import java.rmi.Remote;
41
import java.rmi.RemoteException;
42
import java.rmi.registry.LocateRegistry;
43
import java.rmi.registry.Registry;
44
import java.rmi.server.UnicastRemoteObject;
45
46
public class NoConsoleOutput {
47
48
public static void main(String[] args) throws Exception {
49
System.err.println("\nRegression test for bug 6409194\n");
50
51
/*
52
* Exdecute a subprocess VM that does a bunch of RMI activity
53
* with a logging configuration file that does not specify a
54
* ConsoleHandler and with no legacy sun.rmi.*.logLevel system
55
* properties set.
56
*/
57
String loggingPropertiesFile =
58
System.getProperty("test.src", ".") +
59
File.separatorChar + "logging.properties";
60
ByteArrayOutputStream out = new ByteArrayOutputStream();
61
ByteArrayOutputStream err = new ByteArrayOutputStream();
62
63
// We instantiate a JavaVM that should not produce any console output
64
// (neither on standard output, nor on standard err streams).
65
JavaVM vm = new JavaVM(DoRMIStuff.class.getName(),
66
"-Djava.util.logging.config.file=" + loggingPropertiesFile,
67
"", out, err);
68
vm.execute();
69
70
/*
71
* Verify that the subprocess had no System.out or System.err
72
* output.
73
*/
74
String outString = out.toString();
75
String errString = err.toString();
76
77
System.err.println("-------- subprocess standard output: --------");
78
System.err.print(out);
79
System.err.println("-------- subprocess standard error: --------");
80
System.err.print(err);
81
System.err.println("---------------------------------------------");
82
83
if (outString.length() > 0 || errString.length() > 0) {
84
throw new Error("TEST FAILED: unexpected subprocess output");
85
}
86
87
System.err.println("TEST PASSED");
88
}
89
90
public static class DoRMIStuff {
91
private interface Foo extends Remote {
92
Object echo(Object obj) throws RemoteException;
93
}
94
private static class FooImpl implements Foo {
95
FooImpl() { }
96
public Object echo(Object obj) { return obj; }
97
}
98
public static void main(String[] args) throws Exception {
99
Registry registry = TestLibrary.createRegistryOnUnusedPort();
100
int registryPort = TestLibrary.getRegistryPort(registry);
101
Registry reg = LocateRegistry.getRegistry("", registryPort);
102
FooImpl fooimpl = new FooImpl();
103
UnicastRemoteObject.exportObject(fooimpl, 0);
104
reg.rebind("foo", fooimpl);
105
Foo foostub = (Foo) reg.lookup("foo");
106
FooImpl fooimpl2 = new FooImpl();
107
UnicastRemoteObject.exportObject(fooimpl2, 0);
108
foostub.echo(fooimpl2);
109
UnicastRemoteObject.unexportObject(fooimpl, true);
110
UnicastRemoteObject.unexportObject(fooimpl2, true);
111
}
112
}
113
}
114
115