Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/arraycopy/stress/StressObjectArrayCopy.java
64507 views
1
/*
2
* Copyright (c) 2021, Red Hat, Inc. 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 compiler.arraycopy.stress;
25
26
import java.util.Arrays;
27
import java.util.Random;
28
import jdk.test.lib.Utils;
29
30
public class StressObjectArrayCopy extends AbstractStressArrayCopy {
31
32
private static final Object[] orig = new Object[MAX_SIZE];
33
private static final Object[] test = new Object[MAX_SIZE];
34
35
protected void testWith(int size, int l, int r, int len) {
36
// Seed the test from the original
37
System.arraycopy(orig, 0, test, 0, size);
38
39
// Check the seed is correct
40
{
41
int m = Arrays.mismatch(test, 0, size,
42
orig, 0, size);
43
if (m != -1) {
44
throwSeedError(size, m);
45
}
46
}
47
48
// Perform the tested copy
49
System.arraycopy(test, l, test, r, len);
50
51
// Check the copy has proper contents
52
{
53
int m = Arrays.mismatch(test, r, r+len,
54
orig, l, l+len);
55
if (m != -1) {
56
throwContentsError(l, r, len, r+m);
57
}
58
}
59
60
// Check anything else was not affected: head and tail
61
{
62
int m = Arrays.mismatch(test, 0, r,
63
orig, 0, r);
64
if (m != -1) {
65
throwHeadError(l, r, len, m);
66
}
67
}
68
{
69
int m = Arrays.mismatch(test, r + len, size,
70
orig, r + len, size);
71
if (m != -1) {
72
throwTailError(l, r, len, m);
73
}
74
}
75
}
76
77
public static void main(String... args) {
78
Random rand = Utils.getRandomInstance();
79
for (int c = 0; c < orig.length; c++) {
80
orig[c] = new Object();
81
}
82
new StressObjectArrayCopy().run(rand);
83
}
84
85
}
86
87