Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/HiddenClass/events/events001.java
41161 views
1
/*
2
* Copyright (c) 2020, 2021, 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
/*
25
* @test
26
* @summary JDI test for hidden classes
27
*
28
* @library /vmTestbase
29
* /test/lib
30
* @modules java.base/jdk.internal.misc:+open
31
* @build sun.hotspot.WhiteBox
32
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
33
*
34
* @build nsk.jdi.HiddenClass.events.*
35
*
36
* @run main/othervm
37
* nsk.jdi.HiddenClass.events.events001
38
* -verbose
39
* -arch=${os.family}-${os.simpleArch}
40
* -waittime=5
41
* -debugee.vmkind=java
42
* -transport.address=dynamic
43
* -debugee.vmkeys="-Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
44
* -XX:+WhiteBoxAPI ${test.vm.opts} ${test.java.opts}"
45
*/
46
47
package nsk.jdi.HiddenClass.events;
48
49
import com.sun.jdi.Field;
50
import com.sun.jdi.Method;
51
import com.sun.jdi.ReferenceType;
52
53
import com.sun.jdi.request.EventRequest;
54
55
import nsk.jdi.HiddenClass.events.DebuggerBase;
56
import nsk.jdi.HiddenClass.events.EventHandler;
57
58
import nsk.share.Log;
59
import nsk.share.jdi.ArgumentHandler;
60
61
// This class is the test debugger
62
public class events001 extends DebuggerBase {
63
static final String PACKAGE_NAME = "nsk.jdi.HiddenClass.events";
64
static final String DEBUGGEE_NAME = PACKAGE_NAME + ".events001a";
65
static final String CHECKED_CLASS = PACKAGE_NAME + ".HiddenClass";
66
static final String HC_FILTER = CHECKED_CLASS + "/0x*";
67
68
private events001(ArgumentHandler argHandler) {
69
super(argHandler);
70
}
71
72
public static void main (String args[]) {
73
ArgumentHandler argHandler = new ArgumentHandler(args);
74
75
events001 debugger = new events001(argHandler);
76
System.exit(debugger.run(argHandler) + JCK_STATUS_BASE);
77
}
78
79
public int run(ArgumentHandler argHandler) {
80
boolean testFailed = false;
81
EventRequest breakpointRequest = null;
82
EventRequest classPrepareRequest = null;
83
EventRequest classUnloadRequest = null;
84
EventRequest modWatchpointRequest = null;
85
launchDebuggee(argHandler, DEBUGGEE_NAME);
86
87
try {
88
EventHandler eventHandler = EventHandler.createAndStart(this);
89
90
// sync with debuggee
91
readyCmdSync();
92
93
// request a ClassPrepare event for the hidden class "HiddenClass/0x*"
94
classPrepareRequest = enableClassPrepareRequest(HC_FILTER);
95
96
// request a ClassUnload event for the hidden class "HiddenClass/0x*"
97
classUnloadRequest = enableClassUnloadRequest(HC_FILTER);
98
99
// sync with debuggee
100
runCmdSync();
101
readyCmdSync();
102
103
// There is a latency in getting events from the debuggee
104
// on the debugger side over the wire protocol, so we may
105
// need to wait for ClassPrepareEvent to be posted.
106
ReferenceType hcRefType = eventHandler.waitAndGetHCRefType();
107
108
/* Hidden class has to be prepared at this point. */
109
110
// request a Breakpoint event in the hidden class method "hcMethod"
111
Method method = findMethod(hcRefType, "hcMethod");
112
breakpointRequest = enableBreakpointRequest(method);
113
114
// request a ModificationWatchpoint event on the hidden class field "hcField"
115
Field field = findField(hcRefType, "hcField");
116
modWatchpointRequest = enableModificationWatchpointRequest(field, HC_FILTER);
117
118
// sync with debuggee
119
runCmdSync();
120
doneCmdSync();
121
122
eventHandler.waitForCompleteness();
123
testFailed |= eventHandler.failedStatus();
124
} catch (Throwable t) {
125
log.complain("FAIL: " + t.getMessage());
126
t.printStackTrace(log.getOutStream());
127
testFailed = true;
128
} finally {
129
// disable event requests
130
disableRequest(breakpointRequest, "BreakpointRequest");
131
disableRequest(classPrepareRequest, "ClassPrepareRequest");
132
disableRequest(classUnloadRequest, "ClassUnloadRequest");
133
disableRequest(modWatchpointRequest, "ModificationWatchpointRequest");
134
135
// sync with debuggee
136
quitCmdSync();
137
testFailed |= shutdownDebuggee();
138
}
139
// check test results
140
if (testFailed) {
141
log.complain("# TEST FAILED");
142
return FAILED;
143
}
144
log.display("# TEST PASSED");
145
return PASSED;
146
}
147
}
148
149