Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/share/process/ProcessHandler.java
41159 views
1
/*
2
* Copyright (c) 2011, 2018, 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
package vm.share.process;
24
25
import java.util.List;
26
27
public class ProcessHandler implements MessageInput, MessageOutput {
28
private StreamMessageInput stdout = new StreamMessageInput();
29
private StreamMessageInput stderr = new StreamMessageInput();
30
private StreamMessageOutput stdin = new StreamMessageOutput();
31
32
public ProcessHandler() {
33
}
34
35
public ProcessHandler(ProcessExecutor exec) {
36
bind(exec);
37
}
38
39
public void bind(ProcessExecutor exec) {
40
exec.addStdOutListener(stdout.createListener());
41
exec.addStdErrListener(stderr.createListener());
42
exec.start();
43
stdin.bind(exec.getStdIn());
44
}
45
46
public boolean waitForStart(long timeout) throws InterruptedException {
47
return stdout.waitForStart(timeout) && stderr.waitForStart(timeout);
48
}
49
50
public boolean waitForMessage(long timeout) throws InterruptedException {
51
return stdout.waitForMessage(timeout);
52
}
53
54
public boolean waitForMessage(String msg, long timeout) throws InterruptedException {
55
return stdout.waitForMessage(msg, timeout);
56
}
57
58
public String getMessage() {
59
return stdout.getMessage();
60
}
61
62
public List<String> getMessages() {
63
return stdout.getMessages();
64
}
65
66
public List<String> getMessages(int to) {
67
return stdout.getMessages(to);
68
}
69
70
public List<String> getMessages(int from, int to) {
71
return stdout.getMessages(from, to);
72
}
73
74
public boolean waitForStdErrMessage(String msg, long timeout) throws InterruptedException {
75
return stderr.waitForMessage(msg, timeout);
76
}
77
78
public String getStdErrMessage() {
79
return stderr.getMessage();
80
}
81
82
public boolean waitForFinish(long timeout) throws InterruptedException {
83
return stdout.waitForFinish(timeout) && stderr.waitForFinish(timeout);
84
}
85
86
public void start() {
87
stdin.start();
88
}
89
90
public void send(String msg) {
91
stdin.send(msg);
92
}
93
94
public void finish() {
95
stdin.finish();
96
}
97
98
public void reset() {
99
stdout.reset();
100
stderr.reset();
101
}
102
}
103
104