Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/7100935/TestConjointAtomicArraycopy.java
40942 views
1
/*
2
* Copyright (c) 2011 SAP SE. 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 TestConjointAtomicArraycopy
26
* @bug 7100935
27
* @summary verify that oops are copied element-wise atomic
28
* @run main/othervm -Xint TestConjointAtomicArraycopy
29
* @run main/othervm -Xcomp -Xbatch TestConjointAtomicArraycopy
30
* @author [email protected]
31
*/
32
33
public class TestConjointAtomicArraycopy {
34
35
static volatile Object [] testArray = new Object [4];
36
37
static short[] a1 = new short[8];
38
static short[] a2 = new short[8];
39
static short[] a3 = new short[8];
40
41
static volatile boolean keepRunning = true;
42
43
static void testOopsCopy() throws InterruptedException{
44
45
}
46
47
public static void main(String[] args ) throws InterruptedException{
48
for (int i = 0; i < testArray.length; i++){
49
testArray[i] = new String("A");
50
}
51
52
Thread writer = new Thread (new Runnable(){
53
public void run(){
54
for (int i = 0 ; i < 1000000; i++) {
55
System.arraycopy(testArray, 1, testArray, 0, 3);
56
testArray[2] = new String("a");
57
}
58
}
59
});
60
61
Thread reader = new Thread( new Runnable(){
62
public void run(){
63
while (keepRunning){
64
String name = testArray[2].getClass().getName();
65
if(!(name.endsWith("String"))){
66
throw new RuntimeException("got wrong class name");
67
}
68
}
69
}
70
});
71
keepRunning = true;
72
reader.start();
73
writer.start();
74
writer.join();
75
keepRunning = false;
76
reader.join();
77
}
78
}
79
80