hotspot/test/runtime/verifier/PrimIntArray.java
author hseigel
Wed, 22 Jul 2015 08:00:38 -0400
changeset 31966 aa9c386e1240
child 41705 332239c052cc
permissions -rw-r--r--
8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types Summary: Only allow assignability of arrays of primitive types if the types are identical Reviewed-by: dholmes, gtriantafill
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31966
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     1
/*
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     4
 *
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     8
 *
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    13
 * accompanied this code).
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    14
 *
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    18
 *
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    21
 * questions.
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    22
 *
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    23
 */
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    24
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    25
/*
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    26
 * @test
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    27
 * @bug 8129895
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    28
 * @summary Throw VerifyError when checking assignability of primitive arrays
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    29
 * that are not identical.  For example, [I is not assignable to [B.
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    30
 * @compile primArray.jasm
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    31
 * @compile primArray49.jasm
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    32
 * @run main/othervm -Xverify:all PrimIntArray
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    33
 */
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    34
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    35
// Test that an int[] is not assignable to byte[].
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    36
public class PrimIntArray {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    37
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    38
    public static void main(String args[]) throws Throwable {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    39
        System.out.println("Regression test for bug 8129895");
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    40
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    41
        try {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    42
            Class newClass = Class.forName("primArray");
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    43
            throw new RuntimeException("Expected VerifyError exception not thrown with new verifier");
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    44
        } catch (java.lang.VerifyError e) {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    45
            System.out.println("Test PrimIntArray passed with new verifier");
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    46
        }
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    47
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    48
        try {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    49
            Class newClass = Class.forName("primArray49");
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    50
            throw new RuntimeException("Expected VerifyError exception not thrown by old verifier");
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    51
        } catch (java.lang.VerifyError e) {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    52
            System.out.println("Test PrimIntArray passed with old verifier");
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    53
        }
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    54
    }
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    55
}