test/hotspot/jtreg/runtime/exceptionMsgs/ArrayStoreException/ArrayStoreExceptionTest.java
author stuefe
Wed, 20 Jun 2018 06:51:39 +0200
changeset 50670 e810abb27deb
parent 50601 3fbae7b9ddb5
permissions -rw-r--r--
8205141: runtime/exceptionMsgs/ArrayStoreException/ArrayStoreExceptionTest.java failed with "assert(k->is_objArray_klass()) failed: cast to ObjArrayKlass Reviewed-by: dholmes, goetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50601
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     1
/*
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     3
 * Copyright (c) 2018 SAP SE. All rights reserved.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     5
 *
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
     9
 *
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    14
 * accompanied this code).
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    15
 *
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    19
 *
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    22
 * questions.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    23
 */
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    24
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    25
/**
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    26
 * @test
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    27
 * @summary Test ArrayStoreException message. The message lists
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    28
 *   information about the array types involved.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    29
 * @library /test/lib
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    30
 * @run main ArrayStoreExceptionTest
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    31
 */
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    32
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    33
import java.util.Date;
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    34
import jdk.test.lib.Asserts;
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    35
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    36
/**
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    37
 * Tests the detailed messages of the ArrayStoreException.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    38
 */
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    39
public class ArrayStoreExceptionTest {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    40
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    41
    static {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    42
        System.loadLibrary("ArrayStoreExceptionTest");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    43
    }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    44
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    45
    static void testASMessages(Object from, Object to, String message) throws Exception {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    46
        try {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    47
            System.arraycopy(from, 1, to, 3, 2);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    48
            Asserts.fail("Expected ArrayStoreException not thrown");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    49
        } catch (ArrayStoreException e) {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    50
            Asserts.assertEquals(e.getMessage(), message);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    51
        }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    52
    }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    53
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    54
    static native void doNativeArrayStore(Object[] src, Object dst, int index);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    55
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    56
    static void testNativeASMessages(Object[] array, Object elem, int index, String message)
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    57
        throws Exception {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    58
        try {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    59
            doNativeArrayStore(array, elem, index);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    60
            Asserts.fail("Expected ArrayStoreException not thrown");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    61
        } catch (ArrayStoreException e) {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    62
            Asserts.assertEquals(e.getMessage(), message);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    63
        }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    64
    }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    65
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    66
    public static void main(String[] args) throws Exception {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    67
        try {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    68
            boolean[]    za1 = new boolean[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    69
            byte[]       ba1 = new byte[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    70
            short[]      sa1 = new short[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    71
            char[]       ca1 = new char[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    72
            int[]        ia1 = new int[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    73
            long[]       la1 = new long[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    74
            float[]      fa1 = new float[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    75
            double[]     da1 = new double[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    76
            Object[]     oa1 = new Object[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    77
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    78
            boolean[]    za2 = new boolean[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    79
            byte[]       ba2 = new byte[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    80
            short[]      sa2 = new short[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    81
            char[]       ca2 = new char[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    82
            int[]        ia2 = new int[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    83
            long[]       la2 = new long[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    84
            float[]      fa2 = new float[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    85
            double[]     da2 = new double[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    86
            Object[]     oa2 = new Object[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    87
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    88
            boolean[][]  za3 = new boolean[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    89
            byte[][]     ba3 = new byte[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    90
            short[][]    sa3 = new short[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    91
            char[][]     ca3 = new char[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    92
            int[][]      ia3 = new int[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    93
            long[][]     la3 = new long[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    94
            float[][]    fa3 = new float[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    95
            double[][]   da3 = new double[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    96
            Object[][]   oa3 = new Object[9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    97
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    98
            int[][][]    ia4 = new int[9][9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
    99
            Object[][][] oa4 = new Object[9][9][9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   100
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   101
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   102
            testASMessages(za1, ba2, "arraycopy: type mismatch: can not copy boolean[] into byte[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   103
            testASMessages(ba1, sa2, "arraycopy: type mismatch: can not copy byte[] into short[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   104
            testASMessages(sa1, ca2, "arraycopy: type mismatch: can not copy short[] into char[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   105
            testASMessages(ca1, ia2, "arraycopy: type mismatch: can not copy char[] into int[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   106
            testASMessages(ia1, la2, "arraycopy: type mismatch: can not copy int[] into long[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   107
            testASMessages(la1, fa2, "arraycopy: type mismatch: can not copy long[] into float[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   108
            testASMessages(fa1, da2, "arraycopy: type mismatch: can not copy float[] into double[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   109
            testASMessages(da1, oa2, "arraycopy: type mismatch: can not copy double[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   110
            testASMessages(oa1, za2, "arraycopy: type mismatch: can not copy object array[] into boolean[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   111
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   112
            testASMessages(za1, oa2, "arraycopy: type mismatch: can not copy boolean[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   113
            testASMessages(ba1, za2, "arraycopy: type mismatch: can not copy byte[] into boolean[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   114
            testASMessages(sa1, ba2, "arraycopy: type mismatch: can not copy short[] into byte[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   115
            testASMessages(ca1, sa2, "arraycopy: type mismatch: can not copy char[] into short[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   116
            testASMessages(ia1, ca2, "arraycopy: type mismatch: can not copy int[] into char[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   117
            testASMessages(la1, ia2, "arraycopy: type mismatch: can not copy long[] into int[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   118
            testASMessages(fa1, la2, "arraycopy: type mismatch: can not copy float[] into long[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   119
            testASMessages(da1, fa2, "arraycopy: type mismatch: can not copy double[] into float[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   120
            testASMessages(oa1, da2, "arraycopy: type mismatch: can not copy object array[] into double[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   121
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   122
            testASMessages(za3, ba2, "arraycopy: type mismatch: can not copy object array[] into byte[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   123
            testASMessages(ba3, sa2, "arraycopy: type mismatch: can not copy object array[] into short[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   124
            testASMessages(sa3, ca2, "arraycopy: type mismatch: can not copy object array[] into char[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   125
            testASMessages(ca3, ia2, "arraycopy: type mismatch: can not copy object array[] into int[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   126
            testASMessages(ia3, la2, "arraycopy: type mismatch: can not copy object array[] into long[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   127
            testASMessages(la3, fa2, "arraycopy: type mismatch: can not copy object array[] into float[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   128
            testASMessages(fa3, da2, "arraycopy: type mismatch: can not copy object array[] into double[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   129
            testASMessages(oa3, za2, "arraycopy: type mismatch: can not copy object array[] into boolean[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   130
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   131
            testASMessages(za1, oa3, "arraycopy: type mismatch: can not copy boolean[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   132
            testASMessages(ba1, za3, "arraycopy: type mismatch: can not copy byte[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   133
            testASMessages(sa1, ba3, "arraycopy: type mismatch: can not copy short[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   134
            testASMessages(ca1, sa3, "arraycopy: type mismatch: can not copy char[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   135
            testASMessages(ia1, ca3, "arraycopy: type mismatch: can not copy int[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   136
            testASMessages(la1, ia3, "arraycopy: type mismatch: can not copy long[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   137
            testASMessages(fa1, la3, "arraycopy: type mismatch: can not copy float[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   138
            testASMessages(da1, fa3, "arraycopy: type mismatch: can not copy double[] into object array[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   139
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   140
            //testASMessages(null, ba2,  "arraycopy: type mismatch: can not copy boolean[] into byte[]"); NPE
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   141
            //testASMessages(za1,  null, "arraycopy: type mismatch: can not copy boolean[] into byte[]"); NPE
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   142
            testASMessages("This is not an array", ia2, "arraycopy: source type java.lang.String is not an array");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   143
            testASMessages(la1, "This is not an array", "arraycopy: destination type java.lang.String is not an array");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   144
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   145
            //testASMessages(null, oa2,  "arraycopy: type mismatch: can not copy boolean[] into byte[]"); NPE
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   146
            //testASMessages(oa1,  null, "arraycopy: type mismatch: can not copy boolean[] into byte[]"); NPE
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   147
            testASMessages("This is not an array", oa2, "arraycopy: source type java.lang.String is not an array");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   148
            testASMessages(oa1, "This is not an array", "arraycopy: destination type java.lang.String is not an array");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   149
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   150
            String[] Sa1 = new String[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   151
            Date[]   Da1 = new Date[3];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   152
            String[] Sa2 = new String[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   153
            Date[]   Da2 = new Date[9];
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   154
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   155
            for (int i = 0; i < 3; i++) {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   156
                Sa1[i] = "" + i;
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   157
                oa1[i] = "" + i;
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   158
            }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   159
            testASMessages(Sa1, Da2,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   160
                           "arraycopy: type mismatch: can not copy java.lang.String[] " +
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   161
                           "into java.util.Date[]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   162
            testASMessages(oa1, Da2,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   163
                           "arraycopy: element type mismatch: can not cast one of the " +
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   164
                           "elements of java.lang.Object[] to the type of the destination " +
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   165
                           "array, java.util.Date");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   166
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   167
            // These should succeed.
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   168
            doNativeArrayStore(Sa1, "This is a string", 0);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   169
            doNativeArrayStore(oa1, "This is a string", 2);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   170
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   171
            testNativeASMessages(Da1, "This is not a date", 0,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   172
                                 "type mismatch: can not store java.lang.String to java.util.Date[0]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   173
            testNativeASMessages(Da1, "This is not a date", 2,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   174
                                 "type mismatch: can not store java.lang.String to java.util.Date[2]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   175
            testNativeASMessages(oa3, "This is not a date", 2,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   176
                                 "type mismatch: can not store java.lang.String to java.lang.Object[2][]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   177
            testNativeASMessages(oa4, "This is not a date", 1,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   178
                                 "type mismatch: can not store java.lang.String to java.lang.Object[1][][]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   179
            testNativeASMessages(ia3, "This is not a date", 1,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   180
                                 "type mismatch: can not store java.lang.String to int[1][]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   181
            testNativeASMessages(ia4, "This is not a date", 2,
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   182
                                 "type mismatch: can not store java.lang.String to int[2][][]");
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   183
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   184
        } catch (java.lang.RuntimeException e) {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   185
            throw e;
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   186
        } catch (Exception e) {
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   187
            e.printStackTrace();
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   188
            Asserts.fail("Wrong exception thrown: " + e);
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   189
        }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   190
    }
3fbae7b9ddb5 8204943: Improve message of ArrayStoreException.
goetz
parents:
diff changeset
   191
}