Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/gc/gctests/GcPointerCheckTest/GcPointerCheckTest.java
41159 views
1
/*
2
* Copyright (c) 2011, 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
* @key stress
27
*
28
* @summary converted from VM Testbase gc/gctests/GcPointerCheckTest.
29
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent, jrockit]
30
* VM Testbase readme:
31
* DESCRIPTION
32
* Test that no pointers are broken.
33
*
34
* COMMENTS
35
* This test was ported from JRockit test suite.
36
*
37
* @library /vmTestbase
38
* /test/lib
39
* @run main/othervm -XX:-UseGCOverheadLimit gc.gctests.GcPointerCheckTest.GcPointerCheckTest
40
*/
41
42
package gc.gctests.GcPointerCheckTest;
43
44
import nsk.share.TestFailure;
45
import nsk.share.gc.GC;
46
import nsk.share.gc.ThreadedGCTest;
47
import nsk.share.test.ExecutionController;
48
49
/**
50
* Test that no pointers are broken.
51
*/
52
public class GcPointerCheckTest extends ThreadedGCTest {
53
54
@Override
55
protected Runnable createRunnable(int i) {
56
return new Test();
57
}
58
59
class Test implements Runnable {
60
61
/**
62
* Helper class for linking objects together.
63
*/
64
private class PointerHelper {
65
66
public PointerHelper next;
67
}
68
private PointerHelper first;
69
ExecutionController stresser;
70
71
@Override
72
public void run() {
73
if (stresser == null) {
74
stresser = getExecutionController();
75
}
76
while (stresser.continueExecution()) {
77
testGcPointers();
78
}
79
}
80
81
/**
82
* Create a lot of objects and link them together, then verify
83
* that the pointers are pointing to the correct type of objects.
84
*
85
* @return success if all references points to the correct type
86
* of object.
87
*/
88
public void testGcPointers() {
89
90
int innerIters = 1;
91
int outerIters = 200;
92
93
PointerHelper tmp1;
94
PointerHelper tmp2;
95
96
while (outerIters > 0) {
97
int i = 0;
98
tmp1 = new PointerHelper();
99
this.first = tmp1;
100
101
while (i != innerIters) {
102
i++;
103
tmp2 = new PointerHelper();
104
tmp1.next = tmp2;
105
tmp1 = tmp2;
106
tmp2 = new PointerHelper();
107
}
108
109
outerIters--;
110
111
if (!checkRefs()) {
112
throw new TestFailure("Some references were bad");
113
}
114
}
115
}
116
117
private boolean checkRefs() {
118
PointerHelper iter = this.first;
119
120
for (int i = 0; iter != null; iter = iter.next) {
121
i++;
122
123
if (iter.getClass() != PointerHelper.class) {
124
//("GC causer bad ref on " + i);
125
return false;
126
}
127
}
128
129
return true;
130
}
131
}
132
133
public static void main(String[] args) {
134
GC.runTest(new GcPointerCheckTest(), args);
135
}
136
}
137
138