Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq002.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.createAccessWatchpointRequest;
25
26
import com.sun.jdi.VirtualMachine;
27
import com.sun.jdi.Field;
28
import com.sun.jdi.request.AccessWatchpointRequest;
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.createAccessWatchpointRequest()</b>
40
* properly throws <code>NullPointerException</code> - if field is null.
41
*/
42
public class craccwtchpreq002 {
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.createAccessWatchpointRequest.craccwtchpreq002t";
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 craccwtchpreq002().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
AccessWatchpointRequest awpRequest;
69
String cmd;
70
Field fld = null;
71
72
debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
73
pipe = debuggee.createIOPipe();
74
debuggee.redirectStderr(log, "craccwtchpreq002t.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
if ( !vm.canWatchFieldAccess() ) {
86
log.display(" TEST CANCELLED due to: vm.canWatchFieldAccess() == false");
87
return quitDebuggee(PASSED);
88
}
89
90
// Trying to create AccessWatchpointRequest for null Field parameter
91
try {
92
awpRequest =
93
erManager.createAccessWatchpointRequest(fld);
94
} catch (NullPointerException e) {
95
log.display("TEST PASSED: EventRequestManager.createAccessWatchpointRequest() throws expected "
96
+ e);
97
return quitDebuggee(PASSED);
98
} catch(VMMismatchException e) {
99
log.complain("TEST FAILED: EventRequestManager.createAccessWatchpointRequest() throws unexpected "
100
+ e + "\n\tbut it should throw NullPointerException for a null field");
101
return quitDebuggee(FAILED);
102
} catch(UnsupportedOperationException e) { // specified only in jdk1.4
103
log.complain("WARNING: test has no result. EventRequestManager.createAccessWatchpointRequest() throws "
104
+ e);
105
return quitDebuggee(PASSED);
106
}
107
log.complain("TEST FAILED: EventRequestManager.createAccessWatchpointRequest successfully done,\n\t"
108
+ "but it should throw NullPointerException for a null field");
109
return quitDebuggee(FAILED);
110
}
111
112
private int quitDebuggee(int stat) {
113
pipe.println(COMMAND_QUIT);
114
debuggee.waitFor();
115
return stat;
116
}
117
}
118
119