Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses002.java
41161 views
1
/*
2
* Copyright (c) 2002, 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.ClassLoaderReference.visibleClasses;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import com.sun.jdi.connect.*;
32
import java.io.*;
33
import java.util.*;
34
import java.util.jar.*;
35
36
/**
37
*/
38
public class visibleclasses002 {
39
40
//------------------------------------------------------- immutable common fields
41
42
final static String SIGNAL_READY = "ready";
43
final static String SIGNAL_GO = "go";
44
final static String SIGNAL_QUIT = "quit";
45
46
private static int waitTime;
47
private static int exitStatus;
48
private static ArgumentHandler argHandler;
49
private static Log log;
50
private static Debugee debuggee;
51
private static ReferenceType debuggeeClass;
52
53
//------------------------------------------------------- mutable common fields
54
55
private final static String prefix = "nsk.jdi.ClassLoaderReference.visibleClasses.";
56
private final static String className = "visibleclasses002";
57
private final static String debuggerName = prefix + className;
58
private final static String debuggeeName = debuggerName + "a";
59
60
//------------------------------------------------------- test specific fields
61
62
//------------------------------------------------------- immutable common methods
63
64
public static void main(String argv[]) {
65
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
66
}
67
68
private static void display(String msg) {
69
log.display("debugger > " + msg);
70
}
71
72
private static void complain(String msg) {
73
log.complain("debugger FAILURE > " + msg);
74
}
75
76
public static int run(String argv[], PrintStream out) {
77
78
exitStatus = Consts.TEST_PASSED;
79
80
argHandler = new ArgumentHandler(argv);
81
log = new Log(out, argHandler);
82
waitTime = argHandler.getWaitTime() * 60000;
83
84
try {
85
debuggee = Debugee.prepareDebugee(argHandler, log, debuggeeName);
86
debuggeeClass = debuggee.classByName(debuggeeName);
87
if ( debuggeeClass == null ) {
88
throw new Failure("Class '" + debuggeeName + "' not found.");
89
} else {
90
execTest();
91
}
92
} catch (Exception e) {
93
exitStatus = Consts.TEST_FAILED;
94
complain("Unexpected Exception: " + e.getMessage());
95
e.printStackTrace(out);
96
} finally {
97
debuggee.quit();
98
}
99
100
return exitStatus;
101
}
102
103
//------------------------------------------------------ mutable common method
104
105
private static void execTest() {
106
display("Getting ClassLoaderReference of debuggee's class.");
107
ClassLoaderReference classLoader = debuggeeClass.classLoader();
108
if (classLoader == null) {
109
complain("classLoader() method returned null for debuggee's ReferenceType.");
110
exitStatus = Consts.TEST_FAILED;
111
} else {
112
display("Getting visibleClasses list.");
113
Iterator visibleClasses = classLoader.visibleClasses().iterator();
114
boolean found0 = false;
115
boolean found1 = false;
116
boolean found2 = false;
117
display("Searching for debuggee's ReferenceType in the list...");
118
while (visibleClasses.hasNext()) {
119
ReferenceType refType = (ReferenceType)visibleClasses.next();
120
if (refType.equals(debuggeeClass)) {
121
display("visibleclasses002a ClassType is found in visibleClasses() list of ClassLoaderReference mirror.");
122
found0 = true;
123
} else if (refType instanceof ArrayType) {
124
Type compType;
125
try {
126
compType = ((ArrayType)refType).componentType();
127
if (compType instanceof ClassType && ((ReferenceType)compType).equals(debuggeeClass)) {
128
display("visibleclasses002a[] ArrayType is found in visibleClasses() list of ClassLoaderReference mirror.");
129
found1 = true;
130
} else if (compType instanceof ArrayType) {
131
compType = ((ArrayType)compType).componentType();
132
if (compType instanceof ClassType && ((ReferenceType)compType).equals(debuggeeClass)) {
133
display("visibleclasses002a[][] ArrayType is found in visibleClasses() list of ClassLoaderReference mirror.");
134
found2 = true;
135
}
136
}
137
} catch (ClassNotLoadedException e) {
138
throw new Failure("Unexpected ClassNotLoadedException while getting componentType() of : " + refType);
139
}
140
141
}
142
}
143
if (!found0) {
144
complain("visibleclasses002a ReferenceType is NOT found in visibleClasses() list of ClassLoaderReference mirror.");
145
exitStatus = Consts.TEST_FAILED;
146
}
147
if (!found1) {
148
complain("visibleclasses002a[] ArrayType is NOT found in visibleClasses() list of ClassLoaderReference mirror.");
149
exitStatus = Consts.TEST_FAILED;
150
}
151
if (!found2) {
152
complain("visibleclasses002a[][] ArrayType is NOT found in visibleClasses() list of ClassLoaderReference mirror.");
153
exitStatus = Consts.TEST_FAILED;
154
}
155
}
156
}
157
158
//--------------------------------------------------------- test specific methods
159
160
}
161
//--------------------------------------------------------- test specific classes
162
163