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/definedclasses005.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 definedclasses005 {
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 = "definedclasses005";
57
private final static String debuggerName = prefix + className;
58
private final static String debuggeeName = debuggerName + "a";
59
60
//------------------------------------------------------- test specific fields
61
62
private final static String classLoaderName = prefix + "fields002aClassLoader";
63
private final static String classFieldName = "loadedClass";
64
65
//------------------------------------------------------- immutable common methods
66
67
public static void main(String argv[]) {
68
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
69
}
70
71
private static void display(String msg) {
72
log.display("debugger > " + msg);
73
}
74
75
private static void complain(String msg) {
76
log.complain("debugger FAILURE > " + msg);
77
}
78
79
public static int run(String argv[], PrintStream out) {
80
81
exitStatus = Consts.TEST_PASSED;
82
83
argHandler = new ArgumentHandler(argv);
84
log = new Log(out, argHandler);
85
waitTime = argHandler.getWaitTime() * 60000;
86
87
try {
88
debuggee = Debugee.prepareDebugee(argHandler, log, debuggeeName);
89
debuggeeClass = debuggee.classByName(debuggeeName);
90
if ( debuggeeClass == null ) {
91
throw new Failure("Class '" + debuggeeName + "' not found.");
92
} else {
93
execTest();
94
}
95
} catch (Exception e) {
96
exitStatus = Consts.TEST_FAILED;
97
complain("Unexpected Exception: " + e.getMessage());
98
e.printStackTrace(out);
99
} finally {
100
debuggee.quit();
101
}
102
103
return exitStatus;
104
}
105
106
//------------------------------------------------------ mutable common method
107
108
private static void execTest() {
109
110
while (true) {
111
Field classField = debuggeeClass.fieldByName(classFieldName);
112
if ( classField == null) {
113
complain("Checked field is not found in the debuggee: " + classFieldName);
114
exitStatus = Consts.TEST_FAILED;
115
break;
116
}
117
118
Value classValue = debuggeeClass.getValue(classField);
119
120
ClassObjectReference classObjRef = null;
121
try {
122
classObjRef = (ClassObjectReference)classValue;
123
} catch (Exception e) {
124
complain("Unexpected exception while getting ClassObjectReference : " + e.getMessage());
125
exitStatus = Consts.TEST_FAILED;
126
break;
127
}
128
129
ReferenceType refType1 = classObjRef.reflectedType();
130
display("isPrepared() returned " + refType1.isPrepared() + " for " + refType1);
131
132
display("Getting ClassLoaderReference of ReferenceType: " + refType1 );
133
ClassLoaderReference classLoader = refType1.classLoader();
134
if (classLoader == null) {
135
complain("classLoader() method returned null for ReferenceType: " + refType1);
136
exitStatus = Consts.TEST_FAILED;
137
break;
138
}
139
140
display("Getting definedClasses list.");
141
Iterator definedClasses = classLoader.definedClasses().iterator();
142
display("Checking returned list...");
143
while (definedClasses.hasNext()) {
144
ReferenceType refType = (ReferenceType)definedClasses.next();
145
if (refType.equals(refType1)) {
146
if (refType.isPrepared()) {
147
display("isPrepared() returned true for " + refType);
148
} else {
149
complain("Not-prepared ReferenceType : " + refType + "\n\t is found in definedClasses() list of " + classLoaderName + " mirror.");
150
exitStatus = Consts.TEST_FAILED;
151
}
152
} else {
153
complain("Unexpected ReferenceType : " + refType + "\n\t is found in definedClasses() list of " + classLoaderName + " mirror.");
154
exitStatus = Consts.TEST_FAILED;
155
}
156
}
157
break;
158
}
159
}
160
161
//--------------------------------------------------------- test specific methods
162
163
}
164
//--------------------------------------------------------- test specific classes
165
166