Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/gc/gctests/BigChains/BigChains.java
41155 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/BigChains.
29
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent, jrockit]
30
* VM Testbase readme:
31
* DESCRIPTION
32
* Creates big chains of allocated objects, with a mix of objects
33
* with and without finalizers.
34
*
35
* COMMENTS
36
* This test was ported from JRockit test suite.
37
*
38
* @library /vmTestbase
39
* /test/lib
40
* @run main/othervm -XX:-UseGCOverheadLimit gc.gctests.BigChains.BigChains
41
*/
42
43
package gc.gctests.BigChains;
44
45
import nsk.share.gc.GC;
46
import nsk.share.gc.ThreadedGCTest;
47
48
/**
49
* Test ported from dev test suite. Creates big chains of
50
* allocated objects, with a mix of objects with and without
51
* finalizers.
52
*/
53
public class BigChains extends ThreadedGCTest {
54
55
public static void main(String[] args) {
56
GC.runTest(new BigChains(), args);
57
}
58
59
@Override
60
protected Runnable createRunnable(int i) {
61
62
return new Runnable() {
63
64
/**
65
* Create a big chain of mixed objects and make sure nothing
66
* crashes.
67
*
68
* @return success if the program test could run without any
69
* problems.
70
*/
71
public void run() {
72
73
createChain(100000, true);
74
75
76
int i = 0;
77
78
while (i++ < 100) {
79
createChain(10000, false);
80
}
81
}
82
83
private void createChain(int noof, boolean firstIsFinalizable) {
84
BaseClass first;
85
86
if (firstIsFinalizable) {
87
first = new FinalizerYes();
88
} else {
89
first = new FinalizerNo();
90
}
91
92
BaseClass current = first;
93
94
for (int i = 0; i < noof; i++) {
95
current.next = new FinalizerNo();
96
current = current.next;
97
}
98
99
current.next = first;
100
}
101
};
102
}
103
}
104
105
/**
106
* Helper base class for the BigChains test.
107
*/
108
class BaseClass {
109
110
/**
111
* Base class.
112
*/
113
public BaseClass next;
114
}
115
116
/**
117
* Helper class withfinalizer and counter for number of
118
* calls to the finalize() method.
119
*/
120
class FinalizerYes extends BaseClass {
121
122
private static int noOfFinalized = 0;
123
124
/**
125
* Finalizer for the help class, that increments a counter
126
* for each call to this method.
127
*/
128
public final void finalize() {
129
synchronized (this.getClass()) {
130
FinalizerYes.noOfFinalized++;
131
}
132
}
133
}
134
135
/**
136
* Helper class without finalizer.
137
*/
138
class FinalizerNo extends BaseClass {
139
}
140
141