Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java
41161 views
1
/*
2
* Copyright (c) 2008, 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 nsk.share.aod;
24
25
import nsk.share.*;
26
import nsk.share.jpda.SocketIOPipe;
27
28
/*
29
Class TargetApplication is part of the framework used in the AttachOnDemand tests
30
(tests against Attach API, API from package com.sun.tools.attach).
31
32
This class is used in tests where main test application uses Attach API, but doesn't load agents to the another VM.
33
In these test there are 2 java applications: main application using Attach API and another
34
'dummy' application which should be alive while main application is working.
35
36
To synchronize main and dummy application SocketIOPipe is used: when DummyTargetApplication starts
37
it sends signal that it is ready for test and waits for signal permitting finish execution
38
(socket number used for connection establishing should be passed via command line).
39
*/
40
public class DummyTargetApplication {
41
42
protected Log log = new Log(System.out, true);
43
44
protected AODTargetArgParser argParser;
45
46
protected SocketIOPipe pipe;
47
48
public DummyTargetApplication(String[] args) {
49
argParser = new AODTargetArgParser(args);
50
}
51
52
protected void targetApplicationActions() {
53
// do nothing by default
54
}
55
56
public void runTargetApplication() {
57
pipe = SocketIOPipe.createClientIOPipe(log, "localhost", argParser.getPort(), 0);
58
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
59
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
60
61
targetApplicationActions();
62
63
String signal = pipe.readln();
64
log.display("Signal received: '" + signal + "'");
65
66
if ((signal == null) || !signal.equals(AODTestRunner.SIGNAL_FINISH))
67
throw new TestBug("Unexpected signal: '" + signal + "'");
68
}
69
70
public static void main(String[] args) {
71
new DummyTargetApplication(args).runTargetApplication();
72
}
73
}
74
75