hotspot/test/runtime/verifier/PrimIntArray.java
author alanb
Thu, 01 Dec 2016 15:54:39 +0000
changeset 42309 21f9f3fbc302
parent 41705 332239c052cc
permissions -rw-r--r--
8170599: compiler/** tests using ToolProvider.getSystemClassLoader failing Reviewed-by: hseigel
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
 * @test
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    26
 * @bug 8129895
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    27
 * @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
    28
 * 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
    29
 * @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
    30
 * @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
    31
 * @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
    32
 */
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
// 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
    35
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
    36
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    37
    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
    38
        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
    39
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    40
        try {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    41
            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
    42
            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
    43
        } 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
    44
            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
    45
        }
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
        try {
aa9c386e1240 8129895: New verifier fails to reject erroneous cast from int[] to other arrays of small integer types
hseigel
parents:
diff changeset
    48
            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
    49
            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
    50
        } 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
    51
            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
    52
        }
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
}