kvn@1769: /* trims@1907: * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. kvn@1769: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. kvn@1769: * kvn@1769: * This code is free software; you can redistribute it and/or modify it kvn@1769: * under the terms of the GNU General Public License version 2 only, as kvn@1769: * published by the Free Software Foundation. kvn@1769: * kvn@1769: * This code is distributed in the hope that it will be useful, but WITHOUT kvn@1769: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or kvn@1769: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License kvn@1769: * version 2 for more details (a copy is included in the LICENSE file that kvn@1769: * accompanied this code). kvn@1769: * kvn@1769: * You should have received a copy of the GNU General Public License version kvn@1769: * 2 along with this work; if not, write to the Free Software Foundation, kvn@1769: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. kvn@1769: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. kvn@1769: * kvn@1769: */ kvn@1769: kvn@1769: /** kvn@1769: * @test kvn@1769: * @bug 6892265 kvn@1769: * @summary System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes kvn@1769: * kvn@1769: * @run main/othervm Test kvn@1769: */ kvn@1769: kvn@1769: public class Test { kvn@1769: static final int NCOPY = 1; kvn@1769: static final int OVERFLOW = 1; kvn@1769: static int[] src2 = new int[NCOPY]; kvn@1769: static int[] dst2; kvn@1769: kvn@1769: static void test() { kvn@1769: int N; kvn@1769: int SIZE; kvn@1769: kvn@1769: N = Integer.MAX_VALUE/4 + OVERFLOW; kvn@1769: System.arraycopy(src2, 0, dst2, N, NCOPY); kvn@1769: System.arraycopy(dst2, N, src2, 0, NCOPY); kvn@1769: } kvn@1769: kvn@1769: public static void main(String[] args) { kvn@1769: try { kvn@1769: dst2 = new int[NCOPY + Integer.MAX_VALUE/4 + OVERFLOW]; kvn@1769: } catch (OutOfMemoryError e) { kvn@1769: System.exit(95); // Not enough memory kvn@1769: } kvn@1769: System.out.println("warmup"); kvn@1769: for (int i=0; i <11000; i++) { kvn@1769: test(); kvn@1769: } kvn@1769: System.out.println("start"); kvn@1769: for (int i=0; i <1000; i++) { kvn@1769: test(); kvn@1769: } kvn@1769: System.out.println("finish"); kvn@1769: } kvn@1769: kvn@1769: }