Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocalVariable/genericSignature/gensignature001.java
41161 views
1
/*
2
* Copyright (c) 2004, 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.LocalVariable.genericSignature;
25
26
import nsk.share.*;
27
import nsk.share.jpda.*;
28
import nsk.share.jdi.*;
29
30
import com.sun.jdi.*;
31
import java.util.*;
32
import java.io.*;
33
34
/**
35
* The test for the LocalVariable.genericSignature() method.
36
*
37
* This class is used as debugger part of the test.
38
*/
39
40
public class gensignature001 {
41
42
// communication signals constants
43
static final String READY = "ready";
44
static final String QUIT = "quit";
45
46
static final String PACKAGE_NAME = "nsk.jdi.LocalVariable.genericSignature.";
47
static final String DEBUGEE_CLASS_NAME = PACKAGE_NAME + "gensignature001a";
48
49
// tested class name and signature constants
50
static final String TESTED_CLASS_NAME = DEBUGEE_CLASS_NAME + "$" + "TestedClass";
51
static final String TESTED_CLASS_SIGNATURE = "L" + TESTED_CLASS_NAME.replace('.', '/') + ";";
52
static final String THIS_GENERIC_SIGNATURE = "L" + TESTED_CLASS_NAME.replace('.', '/') + "<TT;TN;>" + ";";
53
54
// tested method name constant
55
static final String TESTED_METHOD_NAME = "testedMethod";
56
57
private static Debugee debugee;
58
private static ReferenceType debugeeClass;
59
60
// list of tested variables names and signatures
61
static final String varsList[][] = {
62
63
// not generic arguments
64
{"arg11PrimBoolean", null},
65
{"arg12PrimInt", null},
66
{"arg13Object", null},
67
{"arg14String", null},
68
{"arg15PrimArrShort", null},
69
{"arg16ObjArrObject", null},
70
71
// generic arguments
72
{"arg21GenObject", "TT;"},
73
{"arg22GenNumber", "TN;"},
74
{"arg23GenObjectArr", "[TT;"},
75
{"arg24GenNumberArr", "[TN;"},
76
{"arg25GenObjectList", "Ljava/util/List<TT;>;"},
77
{"arg26GenNumberList", "Ljava/util/List<TN;>;"},
78
{"arg27GenObjectDerivedList", "Ljava/util/List<+TT;>;"},
79
{"arg28GenNumberDerivedList", "Ljava/util/List<+TN;>;"},
80
81
// not generic variables
82
{"var11PrimBoolean", null},
83
{"var12PrimInt", null},
84
{"var13Object", null},
85
{"var14String", null},
86
{"var15PrimArrShort", null},
87
{"var16ObjArrObject", null},
88
89
// generic variables
90
{"var21GenObject", "TT;"},
91
{"var22GenNumber", "TN;"},
92
{"var23GenObjectArr", "[TT;"},
93
{"var24GenNumberArr", "[TN;"},
94
{"var25GenObjectList", "Ljava/util/List<TT;>;"},
95
{"var26GenNumberList", "Ljava/util/List<TN;>;"},
96
{"var27GenObjectDerivedList", "Ljava/util/List<+TT;>;"},
97
{"var28GenNumberDerivedList", "Ljava/util/List<+TN;>;"},
98
99
100
};
101
102
static ArgumentHandler argHandler;
103
static Log log;
104
105
public static void main (String argv[]) {
106
int result = run(argv, System.out);
107
System.exit(result + Consts.JCK_STATUS_BASE);
108
}
109
110
public static int run (String argv[], PrintStream out) {
111
return new gensignature001().runThis(argv, out);
112
}
113
114
private int runThis (String argv[], PrintStream out) {
115
116
int testResult = Consts.TEST_PASSED;
117
118
argHandler = new ArgumentHandler(argv);
119
log = new Log(out, argHandler);
120
121
debugee = Debugee.prepareDebugee(argHandler, log, DEBUGEE_CLASS_NAME);
122
123
debugeeClass = debugee.classByName(DEBUGEE_CLASS_NAME);
124
if ( debugeeClass == null ) {
125
log.complain("Class '" + DEBUGEE_CLASS_NAME + "' not found.");
126
testResult = Consts.TEST_FAILED;
127
}
128
129
130
log.display("Checking started.");
131
do {
132
ReferenceType testedClass = debugee.classByName(TESTED_CLASS_NAME);
133
log.display("Found tested class: " + testedClass.name());
134
135
Method testedMethod = debugee.methodByName(testedClass, TESTED_METHOD_NAME);
136
log.display("Found tested method: " + testedMethod.name());
137
138
for (int i = 0; i < varsList.length; i++) {
139
140
List localVars = null;
141
try {
142
localVars = testedMethod.variablesByName(varsList[i][0]);
143
} catch (AbsentInformationException e) {
144
log.complain("Unexpected AbsentInformationException while calling variablesByName() for " +
145
varsList[i][0]);
146
testResult = Consts.TEST_FAILED;
147
continue;
148
}
149
if (localVars.size() != 1) {
150
log.complain("Not unique local variable '" + varsList[i][0] + "' : " + localVars.size());
151
testResult = Consts.TEST_FAILED;
152
continue;
153
}
154
log.display("Found local variable: " + varsList[i][0]);
155
156
LocalVariable var = (LocalVariable)localVars.get(0);
157
String expSignature = varsList[i][1];
158
log.display("Getting generic signature for local variable: " + varsList[i][0]);
159
160
String actSignature = "";
161
try {
162
actSignature = var.genericSignature();
163
} catch (Exception e) {
164
log.complain("Unexpected exception while calling genericSignature() for " +
165
varsList[i][0] + " : " + e.getMessage());
166
e.printStackTrace(out);
167
testResult = Consts.TEST_FAILED;
168
continue;
169
}
170
171
if ((expSignature == null && actSignature != null) ||
172
(expSignature != null && !expSignature.equals(actSignature))) {
173
log.complain("Unexpected generic signature for local variable '" + varsList[i][0] + "': " +
174
actSignature + "\n\tExpected generic signature: " + expSignature);
175
testResult = Consts.TEST_FAILED;
176
} else {
177
log.display("\tgot expected generic signature: " + actSignature);
178
}
179
}
180
181
} while (false);
182
log.display("All checking completed.");
183
184
debugee.quit();
185
return testResult;
186
}
187
} // end of gensignature001 class
188
189