hotspot/test/compiler/arraycopy/TestArraysCopyOfNoTypeCheck.java
author thartmann
Thu, 04 Aug 2016 10:34:34 +0200
changeset 40365 3791c1b34e36
parent 40059 c2304140ed64
permissions -rw-r--r--
8136818: Test compiler/arraycopy/TestEliminatedArrayCopyDeopt.java fails with "m1 failed" Summary: Added missing Op_StoreB check to ArrayCopyNode::may_modify_helper(). Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26435
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     1
/*
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     4
 *
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     8
 *
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    13
 * accompanied this code).
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    14
 *
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    18
 *
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    21
 * questions.
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    22
 */
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    23
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    24
/*
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    25
 * @test
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    26
 * @bug 8055910
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    27
 * @summary Arrays.copyOf doesn't perform subtype check
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 28396
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 28396
diff changeset
    30
 *                   compiler.arraycopy.TestArraysCopyOfNoTypeCheck
26435
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    31
 */
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    32
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 28396
diff changeset
    33
package compiler.arraycopy;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 28396
diff changeset
    34
26435
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    35
import java.util.Arrays;
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    36
28396
7fe4347e6792 6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents: 26435
diff changeset
    37
public class TestArraysCopyOfNoTypeCheck {
26435
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    38
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    39
    static class A {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    40
    }
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    41
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    42
    static class B extends A {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    43
    }
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    44
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    45
    static B[] test(A[] arr) {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    46
        return Arrays.copyOf(arr, 10, B[].class);
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    47
    }
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    48
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    49
    static public void main(String[] args) {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    50
        A[] arr = new A[20];
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    51
        for (int i = 0; i < 20000; i++) {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    52
            test(arr);
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    53
        }
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    54
        A[] arr2 = new A[20];
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    55
        arr2[0] = new A();
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    56
        boolean exception = false;
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    57
        try {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    58
            test(arr2);
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    59
        } catch (ArrayStoreException ase) {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    60
            exception = true;
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    61
        }
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    62
        if (!exception) {
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    63
            throw new RuntimeException("TEST FAILED: ArrayStoreException not thrown");
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    64
        }
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    65
    }
b446202ac824 8055910: closed/java/util/Collections/CheckedCollections.java failed with ClassCastException not thrown
roland
parents:
diff changeset
    66
}