Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/Field/hashCode/hashcode001.java
41161 views
1
/*
2
* Copyright (c) 2000, 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
25
package nsk.jdi.Field.hashCode;
26
27
import nsk.share.*;
28
import nsk.share.jpda.*;
29
import nsk.share.jdi.*;
30
31
import com.sun.jdi.*;
32
import java.util.*;
33
import java.io.*;
34
35
public class hashcode001 {
36
private static Log log;
37
private final static String prefix = "nsk.jdi.Field.hashCode.";
38
private final static String className = "hashcode001";
39
private final static String debugerName = prefix + className;
40
private final static String debugeeName = debugerName + "a";
41
42
public static void main(String argv[]) {
43
System.exit(95 + run(argv, System.out));
44
}
45
46
public static int run(String argv[], PrintStream out) {
47
ArgumentHandler argHandler = new ArgumentHandler(argv);
48
log = new Log(out, argHandler);
49
Binder binder = new Binder(argHandler, log);
50
Debugee debugee = binder.bindToDebugee(debugeeName
51
+ (argHandler.verbose() ? " -verbose" : ""));
52
IOPipe pipe = new IOPipe(debugee);
53
boolean testFailed = false;
54
List fields;
55
56
// Connect with debugee and resume it
57
debugee.redirectStderr(out);
58
debugee.resume();
59
String line = pipe.readln();
60
if (line == null) {
61
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - null");
62
return 2;
63
}
64
if (!line.equals("ready")) {
65
log.complain("debuger FAILURE> UNEXPECTED debugee's signal - "
66
+ line);
67
return 2;
68
}
69
else {
70
log.display("debuger> debugee's \"ready\" signal recieved.");
71
}
72
73
// Get all fields from debugee
74
ReferenceType refType = debugee.classByName(debugeeName);
75
if (refType == null) {
76
log.complain("debuger FAILURE> Class " + debugeeName
77
+ " not found.");
78
return 2;
79
}
80
try {
81
fields = refType.allFields();
82
} catch (Exception e) {
83
log.complain("debuger FAILURE> Can't get fields from class");
84
log.complain("debuger FAILURE> Exception: " + e);
85
return 2;
86
}
87
int totalFields = fields.size();
88
if (totalFields < 1) {
89
log.complain("debuger FAILURE> Total number of fields read "
90
+ totalFields);
91
return 2;
92
}
93
log.display("debuger> Total fields found: " + fields.size());
94
Iterator fieldsIterator = fields.iterator();
95
for (int i = 0; fieldsIterator.hasNext(); i++) {
96
Field field = (Field)fieldsIterator.next();
97
int hash1 = field.hashCode();
98
int hash2 = field.hashCode();
99
// hashCode() returns int value and always should be the same
100
// for one field
101
log.display("debuger> " + i + " field " + field.name()
102
+ "(" + field.typeName() + ") has hashCode = " + hash1);
103
if (hash1 != hash2) {
104
log.complain("debuger FAILURE> Two different hash codes for "
105
+ "field " + field.name() + " (" + field.typeName()
106
+ "): " + hash1 + " and " + hash2 + ". Should be "
107
+ "the same");
108
testFailed = true;
109
}
110
}
111
pipe.println("quit");
112
debugee.waitFor();
113
114
int status = debugee.getStatus();
115
if (testFailed) {
116
log.complain("debuger FAILURE> TEST FAILED");
117
return 2;
118
} else {
119
if (status == 95) {
120
log.display("debuger> expected Debugee's exit "
121
+ "status - " + status);
122
return 0;
123
} else {
124
log.complain("debuger FAILURE> UNEXPECTED Debugee's exit "
125
+ "status (not 95) - " + status);
126
return 2;
127
}
128
}
129
}
130
}
131
132