author | shade |
Wed, 09 Jan 2019 15:53:56 +0100 | |
changeset 53250 | 10621b0e8e38 |
child 53523 | 4c5184c56dc2 |
permissions | -rw-r--r-- |
53250
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
1 |
/* |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Red Hat, Inc. All rights reserved. |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
4 |
* |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
8 |
* |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
13 |
* accompanied this code). |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
14 |
* |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
18 |
* |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
21 |
* questions. |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
22 |
*/ |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
23 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
24 |
/** |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
25 |
* @test TestArraycopyCheckcast |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
26 |
* @key gc |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
27 |
* @requires vm.gc.Epsilon & !vm.graal.enabled |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
28 |
* @summary Epsilon is able to handle checkcasted array copies |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
29 |
* @library /test/lib |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
30 |
* @bug 8215724 |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
31 |
* |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
32 |
* @run main/othervm -Xmx1g -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC TestArraycopyCheckcast |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
33 |
* @run main/othervm -Xmx1g -Xint -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC TestArraycopyCheckcast |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
34 |
* @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC TestArraycopyCheckcast |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
35 |
* @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:TieredStopAtLevel=1 -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC TestArraycopyCheckcast |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
36 |
* @run main/othervm -Xmx1g -Xbatch -Xcomp -XX:-TieredCompilation -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC TestArraycopyCheckcast |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
37 |
*/ |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
38 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
39 |
import java.util.Random; |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
40 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
41 |
public class TestArraycopyCheckcast { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
42 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
43 |
static int COUNT = Integer.getInteger("count", 1000); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
44 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
46 |
Object[] src = new Object[COUNT]; |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
47 |
Object[] dst = new B[COUNT]; |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
48 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
49 |
// Test 1. Copy nulls, should succeed |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
50 |
try { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
51 |
System.arraycopy(src, 0, dst, 0, COUNT); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
52 |
} catch (ArrayStoreException e) { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
53 |
throw new IllegalStateException("Should have completed"); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
54 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
55 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
56 |
// Test 2. Copying incompatible type, should fail |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
57 |
for (int c = 0; c < COUNT; c++) { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
58 |
src[c] = new A(); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
59 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
60 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
61 |
try { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
62 |
System.arraycopy(src, 0, dst, 0, COUNT); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
63 |
throw new IllegalStateException("Should have failed with ArrayStoreException"); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
64 |
} catch (ArrayStoreException e) { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
65 |
// Expected |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
66 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
67 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
68 |
// Test 3. Copying compatible type, should succeeded |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
69 |
for (int c = 0; c < COUNT; c++) { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
70 |
src[c] = new C(); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
71 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
72 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
73 |
try { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
74 |
System.arraycopy(src, 0, dst, 0, COUNT); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
75 |
} catch (ArrayStoreException e) { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
76 |
throw new IllegalStateException("Should have completed"); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
77 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
78 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
79 |
for (int c = 0; c < COUNT; c++) { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
80 |
if (src[c] != dst[c]) { |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
81 |
throw new IllegalStateException("Copy failed at index " + c); |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
82 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
83 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
84 |
} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
85 |
|
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
86 |
static class A {} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
87 |
static class B extends A {} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
88 |
static class C extends B {} |
10621b0e8e38
8215724: Epsilon: ArrayStoreExceptionTest.java fails; missing arraycopy check
shade
parents:
diff
changeset
|
89 |
} |