Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses004.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.definedClasses;
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 definedclasses004 {
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.definedClasses.";
56
private final static String className = "definedclasses004";
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
107
display("Getting ClassLoaderReference of class : " + debuggeeName);
108
ClassLoaderReference classLoader = debuggeeClass.classLoader();
109
if (classLoader == null) {
110
complain("classLoader() method returned null for ReferenceType mirror of : " + debuggeeName);
111
exitStatus = Consts.TEST_FAILED;
112
} else {
113
display("Getting definedClasses() list of : " + classLoader );
114
Iterator definedClasses = classLoader.definedClasses().iterator();
115
display("Checking isPrepared() result for ReferenceType's in the list...");
116
int count = 0;
117
while (definedClasses.hasNext()) {
118
ReferenceType refType = (ReferenceType)definedClasses.next();
119
count++;
120
if (!(refType instanceof ArrayType)) {
121
if (!refType.isPrepared()) {
122
complain("isPrepared() returned false for : " + refType);
123
exitStatus = Consts.TEST_FAILED;
124
}
125
}
126
}
127
display("Total number of items in definedClasses() list : " + count);
128
}
129
}
130
131
//--------------------------------------------------------- test specific methods
132
133
}
134
//--------------------------------------------------------- test specific classes
135
136