test/compiler/6892265/Test.java

Fri, 02 Dec 2011 15:11:40 -0800

author
jcoomes
date
Fri, 02 Dec 2011 15:11:40 -0800
changeset 3301
aed8bf036ce2
parent 1907
c18cbe5936b8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added tag hs23-b07 for changeset 6de8c9ba5907

kvn@1769 1 /*
trims@1907 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
kvn@1769 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
kvn@1769 4 *
kvn@1769 5 * This code is free software; you can redistribute it and/or modify it
kvn@1769 6 * under the terms of the GNU General Public License version 2 only, as
kvn@1769 7 * published by the Free Software Foundation.
kvn@1769 8 *
kvn@1769 9 * This code is distributed in the hope that it will be useful, but WITHOUT
kvn@1769 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kvn@1769 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kvn@1769 12 * version 2 for more details (a copy is included in the LICENSE file that
kvn@1769 13 * accompanied this code).
kvn@1769 14 *
kvn@1769 15 * You should have received a copy of the GNU General Public License version
kvn@1769 16 * 2 along with this work; if not, write to the Free Software Foundation,
kvn@1769 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
kvn@1769 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
kvn@1769 22 *
kvn@1769 23 */
kvn@1769 24
kvn@1769 25 /**
kvn@1769 26 * @test
kvn@1769 27 * @bug 6892265
kvn@1769 28 * @summary System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
kvn@1769 29 *
kvn@1769 30 * @run main/othervm Test
kvn@1769 31 */
kvn@1769 32
kvn@1769 33 public class Test {
kvn@1769 34 static final int NCOPY = 1;
kvn@1769 35 static final int OVERFLOW = 1;
kvn@1769 36 static int[] src2 = new int[NCOPY];
kvn@1769 37 static int[] dst2;
kvn@1769 38
kvn@1769 39 static void test() {
kvn@1769 40 int N;
kvn@1769 41 int SIZE;
kvn@1769 42
kvn@1769 43 N = Integer.MAX_VALUE/4 + OVERFLOW;
kvn@1769 44 System.arraycopy(src2, 0, dst2, N, NCOPY);
kvn@1769 45 System.arraycopy(dst2, N, src2, 0, NCOPY);
kvn@1769 46 }
kvn@1769 47
kvn@1769 48 public static void main(String[] args) {
kvn@1769 49 try {
kvn@1769 50 dst2 = new int[NCOPY + Integer.MAX_VALUE/4 + OVERFLOW];
kvn@1769 51 } catch (OutOfMemoryError e) {
kvn@1769 52 System.exit(95); // Not enough memory
kvn@1769 53 }
kvn@1769 54 System.out.println("warmup");
kvn@1769 55 for (int i=0; i <11000; i++) {
kvn@1769 56 test();
kvn@1769 57 }
kvn@1769 58 System.out.println("start");
kvn@1769 59 for (int i=0; i <1000; i++) {
kvn@1769 60 test();
kvn@1769 61 }
kvn@1769 62 System.out.println("finish");
kvn@1769 63 }
kvn@1769 64
kvn@1769 65 }

mercurial