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/events001a.java
41161 views
1
/*
2
* Copyright (c) 2020, 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.HiddenClass.events;
25
26
import nsk.jdi.HiddenClass.events.DebuggeeBase;
27
import nsk.jdi.HiddenClass.events.HiddenClass;
28
import nsk.jdi.HiddenClass.events.HCInterf;
29
import nsk.share.jdi.ArgumentHandler;
30
import sun.hotspot.WhiteBox;
31
32
/* Debuggee class. */
33
class events001a extends DebuggeeBase {
34
private final WhiteBox WB = WhiteBox.getWhiteBox();
35
36
private events001a(ArgumentHandler argHandler) {
37
super(argHandler);
38
}
39
40
public static void main(String args[]) {
41
ArgumentHandler argHandler = new ArgumentHandler(args);
42
events001a testApp = new events001a(argHandler);
43
int status = testApp.runIt();
44
System.exit(DebuggerBase.JCK_STATUS_BASE + status);
45
}
46
47
public int runIt() {
48
int status = DebuggerBase.PASSED;
49
logMsg("\nDebuggee: started");
50
51
try {
52
testHiddenClass();
53
} catch (Throwable t) {
54
status = DebuggerBase.FAILED;
55
logMsg("FAIL: Throwable was caught in debuggee main: " + t);
56
}
57
logMsg("\nDebuggee: finished");
58
return status;
59
}
60
61
public void testHiddenClass() throws Exception {
62
syncWithDebugger();
63
64
// Define a hidden class.
65
Class<?> hc = HiddenClass.defineHiddenClass();
66
logMsg("Debuggee: defined a hidden class: " + hc.getName());
67
68
// It is impossible to use a hidden class name to define a variable,
69
// so we use the interface which the tested hidden class implements.
70
HCInterf hcObj = (HCInterf)hc.newInstance();
71
logMsg("Debuggee: created an instance of a hidden class: " + hc.getName());
72
73
syncWithDebugger();
74
75
// Invoke a hidden class method.
76
logMsg("Debuggee: invoking a method of a hidden class: " + hc.getName());
77
hcObj.hcMethod();
78
79
// Provoke a hidden class unload event.
80
// One more hidden class has to be defined to provoke class unload.
81
// The first hidden class can not be unloaded. There are some JDI Field's
82
// or Method's associated with the hidden class which keep it alive.
83
logMsg("Debuggee: started provoking class unload events");
84
Class<?> hcForUnload = HiddenClass.defineHiddenClass();
85
hcForUnload = null;
86
WB.fullGC(); // force full GC with WB to get hidden class unloaded
87
logMsg("Debuggee: finished provoking class unload events");
88
89
quitSyncWithDebugger();
90
}
91
}
92
93