Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/hashCode/hashcode001.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.EventQueue.hashCode;
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.request.*;
32
import com.sun.jdi.event.*;
33
import com.sun.jdi.connect.*;
34
import java.io.*;
35
import java.util.*;
36
37
/**
38
* The debugger application of the test.
39
*/
40
public class hashcode001 {
41
42
//------------------------------------------------------- immutable common fields
43
44
final static String SIGNAL_READY = "ready";
45
final static String SIGNAL_GO = "go";
46
final static String SIGNAL_QUIT = "quit";
47
48
private static int waitTime;
49
private static int exitStatus;
50
private static ArgumentHandler argHandler;
51
private static Log log;
52
private static Debugee debuggee;
53
private static ReferenceType debuggeeClass;
54
55
//------------------------------------------------------- mutable common fields
56
57
private final static String prefix = "nsk.jdi.EventQueue.hashCode.";
58
private final static String className = "hashcode001";
59
private final static String debuggerName = prefix + className;
60
private final static String debuggeeName = debuggerName + "a";
61
62
//------------------------------------------------------- test specific fields
63
64
//------------------------------------------------------- immutable common methods
65
66
public static void main(String argv[]) {
67
System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out));
68
}
69
70
private static void display(String msg) {
71
log.display("debugger > " + msg);
72
}
73
74
private static void complain(String msg) {
75
log.complain("debugger FAILURE > " + msg);
76
}
77
78
public static int run(String argv[], PrintStream out) {
79
80
exitStatus = Consts.TEST_PASSED;
81
82
argHandler = new ArgumentHandler(argv);
83
log = new Log(out, argHandler);
84
waitTime = argHandler.getWaitTime() * 60000;
85
86
debuggee = Debugee.prepareDebugee(argHandler, log, debuggeeName);
87
88
debuggeeClass = debuggee.classByName(debuggeeName);
89
if ( debuggeeClass == null ) {
90
complain("Class '" + debuggeeName + "' not found.");
91
exitStatus = Consts.TEST_FAILED;
92
}
93
94
execTest();
95
96
debuggee.quit();
97
98
return exitStatus;
99
}
100
101
//------------------------------------------------------ mutable common method
102
103
private static void execTest() {
104
105
display("Checking hashCode() method for EventQueue object");
106
107
EventQueue eventQueue = debuggee.VM().eventQueue();
108
int hCode = eventQueue.hashCode();
109
110
if (hCode == 0) {
111
complain("hashCode() returns 0 for EventQueue object");
112
exitStatus = Consts.TEST_FAILED;
113
}
114
115
int hCode1 = eventQueue.hashCode();
116
if (hCode != hCode1) {
117
complain("hashCode() is not consistent for EventQueue object" +
118
"\n\t first value :" + hCode + " ; second value : " + hCode1);
119
exitStatus = Consts.TEST_FAILED;
120
}
121
122
// get new reference to the same EventQueue and get hash code.
123
hCode1 = debuggee.VM().eventQueue().hashCode();
124
if (hCode != hCode1) {
125
complain("hashCode() does not return same value for equal EventQueue object " +
126
"\n\t first value :" + hCode + " ; second value : " + hCode1);
127
exitStatus = Consts.TEST_FAILED;
128
}
129
130
display("hashCode() returns for EventQueue object : " + hCode);
131
132
display("Checking completed!");
133
debuggee.resume();
134
}
135
136
//--------------------------------------------------------- test specific methods
137
138
}
139
//--------------------------------------------------------- test specific classes
140
141