Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/gc/gctests/FinalizeTest04/FinalizeTest04.java
41161 views
1
/*
2
* Copyright (c) 2007, 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 randomness
27
*
28
* @summary converted from VM Testbase gc/gctests/FinalizeTest04.
29
* VM Testbase keywords: [gc, stress, stressopt, nonconcurrent]
30
*
31
* @library /vmTestbase
32
* /test/lib
33
* @run main/othervm -XX:-UseGCOverheadLimit gc.gctests.FinalizeTest04.FinalizeTest04
34
*/
35
36
package gc.gctests.FinalizeTest04;
37
38
import nsk.share.test.*;
39
import nsk.share.gc.*;
40
41
/**
42
* Test that synchronization between GC and finalizer thread
43
* (if any) is correct.
44
*
45
* This test creates objects that do GC-related work in finalizer,
46
* e.g. call System.gc(), System.runFinalization(), Algorithms.eatMemory().
47
*
48
* @see nsk.share.gc.Algorithms#eatMemory()
49
* @see java.lang.System#gc()
50
* @see java.lang.System#runFinalization()
51
*/
52
public class FinalizeTest04 extends GCTestBase {
53
54
private int objectSize = 100;
55
private int objectCount = 100;
56
private ExecutionController stresser;
57
58
private class FinMemoryObject2 extends FinMemoryObject {
59
60
public FinMemoryObject2(int size) {
61
super(size);
62
}
63
64
protected void finalize() {
65
super.finalize();
66
System.gc();
67
Algorithms.eatMemory(stresser);
68
System.runFinalization();
69
System.gc();
70
Algorithms.eatMemory(stresser);
71
System.gc();
72
}
73
}
74
75
public void run() {
76
stresser = new Stresser(runParams.getStressOptions());
77
stresser.start(runParams.getIterations());
78
for (int i = 0; i < objectCount; ++i) {
79
new FinMemoryObject2(objectSize);
80
}
81
Algorithms.eatMemory(stresser);
82
}
83
84
public static void main(String[] args) {
85
GC.runTest(new FinalizeTest04(), args);
86
}
87
}
88
89