Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine03/VirtualMachine03.java
41160 views
1
/*
2
* Copyright (c) 2008, 2020, 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
* @test
26
*
27
* @summary converted from VM Testbase nsk/aod/VirtualMachine/VirtualMachine03.
28
* VM Testbase keywords: [feature_282, jdk]
29
* VM Testbase readme:
30
* Description :
31
* Test checks work of Attach API (com.sun.tools.attach).
32
* Test is based on the nsk.share.aod framework.
33
* Test checks semantics of the method VirtualMachine.equals(Object obj).
34
*
35
* @library /vmTestbase /test/hotspot/jtreg/vmTestbase
36
* /test/lib
37
* @build nsk.share.aod.DummyTargetApplication
38
* @run main/othervm
39
* -Djdk.attach.allowAttachSelf
40
* -XX:+UsePerfData
41
* nsk.aod.VirtualMachine.VirtualMachine03.VirtualMachine03
42
* -jdk ${test.jdk}
43
* -javaOpts="-XX:+UsePerfData ${test.vm.opts} ${test.java.opts}"
44
* -target nsk.share.aod.DummyTargetApplication
45
*/
46
47
package nsk.aod.VirtualMachine.VirtualMachine03;
48
49
import com.sun.tools.attach.VirtualMachine;
50
import nsk.share.aod.AODTestRunner;
51
import nsk.share.test.TestUtils;
52
53
/*
54
* Test checks method VirtualMachine.equals(Object)
55
*/
56
public class VirtualMachine03 extends AODTestRunner {
57
58
public VirtualMachine03(String[] args) {
59
super(args);
60
}
61
62
public void doTestActions(String targetVMId) throws Throwable {
63
String currentVMId = getCurrentVMId();
64
65
VirtualMachine vm1 = VirtualMachine.attach(currentVMId);
66
try {
67
VirtualMachine vm2 = VirtualMachine.attach(targetVMId);
68
try {
69
TestUtils.assertEquals(vm1.id(), currentVMId, "vm.id() returns unexpected value: " + vm1.id());
70
TestUtils.assertEquals(vm2.id(), targetVMId, "vm.id() returns unexpected value: " + vm2.id());
71
72
TestUtils.assertTrue(!vm1.equals(vm2), vm1 + ".equals(" + vm2 + ") returns 'true'");
73
74
checkVM(vm1);
75
checkVM(vm2);
76
} finally {
77
vm2.detach();
78
}
79
} finally {
80
vm1.detach();
81
}
82
}
83
84
void checkVM(VirtualMachine vm1) throws Throwable {
85
TestUtils.assertEquals(vm1, vm1, "vm.equals(itself) returns 'false'");
86
87
// create one more VirtualMachine object for the same VM
88
VirtualMachine vm2 = VirtualMachine.attach(vm1.id());
89
try {
90
TestUtils.assertEquals(vm1, vm2, vm1 + ".equals(" + vm2 + ") returns 'false'");
91
TestUtils.assertTrue(vm1.hashCode() == vm2.hashCode(), "vm.hashCode() returns different values for " + vm1 + " and " + vm2);
92
TestUtils.assertEquals(vm1.provider(), vm2.provider(), "vm.provider() returns non-equals objects for " + vm1 + " and " + vm2);
93
} finally {
94
vm2.detach();
95
}
96
97
TestUtils.assertTrue(!vm1.equals(""), "vm.equals(String) returns 'true'");
98
99
TestUtils.assertTrue(!vm1.equals(null), "vm.equals(null) returns 'true'");
100
}
101
102
public static void main(String[] args) {
103
new VirtualMachine03(args).runTest();
104
}
105
}
106
107