Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadEvent/className/classname001a.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.ClassUnloadEvent.className;
25
26
import java.io.*;
27
import nsk.share.*;
28
import nsk.share.jpda.*;
29
import nsk.share.jdi.*;
30
31
32
// This class is the debugged application in the test
33
34
class classname001a {
35
static final int PASSED = 0;
36
static final int FAILED = 2;
37
static final int JCK_STATUS_BASE = 95;
38
39
static final String PREFIX = "nsk.jdi.ClassUnloadEvent.className";
40
static final String CHECKED_CLASS = PREFIX + ".classname001b";
41
42
public static void main(String args[]) {
43
classname001a _classname001a = new classname001a();
44
System.exit(JCK_STATUS_BASE + _classname001a.run(args));
45
}
46
47
int run (String args[]) {
48
ArgumentHandler argHandler = new ArgumentHandler(args);
49
IOPipe pipe = argHandler.createDebugeeIOPipe();
50
51
// define directory to class files
52
String loadClassDir = (argHandler.getArguments())[0] + File.separator + "loadclass";
53
54
// notify debugger that debugee is ready
55
pipe.println(classname001.COMMAND_READY);
56
57
// wait for a command to load checked class
58
String command = pipe.readln();
59
if (!command.equals(classname001.COMMAND_LOAD)) {
60
System.err.println("TEST BUG: unexpected command: " + command);
61
return FAILED;
62
}
63
64
// load class for further unloading
65
ClassUnloader classUnloader = new ClassUnloader();
66
try {
67
classUnloader.loadClass(CHECKED_CLASS, loadClassDir);
68
} catch (Exception ex) {
69
System.err.println("Unexpected exception while loading classname001b:");
70
System.err.println(ex);
71
return FAILED;
72
}
73
74
// notify debugger that checked class is loaded
75
pipe.println(classname001.COMMAND_LOADED);
76
77
// turn off pipe pinging
78
pipe.setPingTimeout(0);
79
80
// wait for a command to unload checked class
81
command = pipe.readln();
82
if (!command.equals(classname001.COMMAND_UNLOAD)) {
83
System.err.println("TEST BUG: unexpected command: " + command);
84
return FAILED;
85
}
86
87
// try to unload checked class
88
boolean unloaded = classUnloader.unloadClass();
89
90
if (!unloaded) {
91
pipe.println(classname001.COMMAND_LOADED);
92
} else {
93
pipe.println(classname001.COMMAND_UNLOADED);
94
}
95
96
// wait for a command to exit
97
command = pipe.readln();
98
if (!command.equals(classname001.COMMAND_QUIT)) {
99
System.err.println("TEST BUG: unknown command: " + command);
100
return FAILED;
101
}
102
return PASSED;
103
}
104
}
105
106