Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq002.java
41161 views
1
/*
2
* Copyright (c) 2001, 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
24
package nsk.jdi.EventRequestManager.createBreakpointRequest;
25
26
import com.sun.jdi.VirtualMachine;
27
import com.sun.jdi.Location;
28
import com.sun.jdi.request.BreakpointRequest;
29
import com.sun.jdi.request.EventRequestManager;
30
import com.sun.jdi.VMMismatchException;
31
import java.io.*;
32
33
import nsk.share.*;
34
import nsk.share.jpda.*;
35
import nsk.share.jdi.*;
36
37
/**
38
* The test checks that the JDI method
39
* <b>com.sun.jdi.request.EventRequestManager.createBreakpointRequest()</b>
40
* properly throws <code>NullPointerException</code> - if location is null.
41
*/
42
public class crbreakpreq002 {
43
public static final int PASSED = 0;
44
public static final int FAILED = 2;
45
public static final int JCK_STATUS_BASE = 95;
46
static final String DEBUGGEE_CLASS =
47
"nsk.jdi.EventRequestManager.createBreakpointRequest.crbreakpreq002t";
48
static final String COMMAND_READY = "ready";
49
static final String COMMAND_QUIT = "quit";
50
51
private ArgumentHandler argHandler;
52
private Log log;
53
private IOPipe pipe;
54
private Debugee debuggee;
55
56
public static void main (String argv[]) {
57
System.exit(run(argv,System.out) + JCK_STATUS_BASE);
58
}
59
60
public static int run(String argv[], PrintStream out) {
61
return new crbreakpreq002().runIt(argv, out);
62
}
63
64
private int runIt(String args[], PrintStream out) {
65
argHandler = new ArgumentHandler(args);
66
log = new Log(out, argHandler);
67
Binder binder = new Binder(argHandler, log);
68
BreakpointRequest bpRequest;
69
String cmd;
70
Location loc = null;
71
72
debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
73
pipe = debuggee.createIOPipe();
74
debuggee.redirectStderr(log, "crbreakpreq002t.err> ");
75
VirtualMachine vm = debuggee.VM();
76
EventRequestManager erManager = vm.eventRequestManager();
77
debuggee.resume();
78
cmd = pipe.readln();
79
if (!cmd.equals(COMMAND_READY)) {
80
log.complain("TEST BUG: unknown debuggee's command: "
81
+ cmd);
82
return quitDebuggee(FAILED);
83
}
84
85
// Trying to create BreakpointRequest for a null Location parameter
86
try {
87
bpRequest =
88
erManager.createBreakpointRequest(loc);
89
} catch (NullPointerException e) {
90
log.display("TEST PASSED: EventRequestManager.createBreakpointRequest() throws expected "
91
+ e);
92
return quitDebuggee(PASSED);
93
} catch(VMMismatchException e) {
94
log.complain("TEST FAILED: EventRequestManager.createBreakpointRequest() throws unexpected "
95
+ e + "\n\tbut it should throw NullPointerException for a null location");
96
return quitDebuggee(FAILED);
97
} catch(UnsupportedOperationException e) { // specified only in jdk1.4
98
log.complain("WARNING: test has no result. EventRequestManager.createBreakpointRequest() throws "
99
+ e);
100
return quitDebuggee(PASSED);
101
}
102
log.complain("TEST FAILED: EventRequestManager.createBreakpointRequest() successfully done,\n\t"
103
+ "but it should throw NullPointerException for a null location");
104
return quitDebuggee(FAILED);
105
}
106
107
private int quitDebuggee(int stat) {
108
pipe.println(COMMAND_QUIT);
109
debuggee.waitFor();
110
return stat;
111
}
112
}
113
114