Wed, 09 May 2012 13:07:42 -0700
Added tag jdk8-b37 for changeset bfcf92bfefb8
cfang@1335 | 1 | /* |
trims@1907 | 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
cfang@1335 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cfang@1335 | 4 | * |
cfang@1335 | 5 | * This code is free software; you can redistribute it and/or modify it |
cfang@1335 | 6 | * under the terms of the GNU General Public License version 2 only, as |
cfang@1335 | 7 | * published by the Free Software Foundation. |
cfang@1335 | 8 | * |
cfang@1335 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
cfang@1335 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cfang@1335 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cfang@1335 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
cfang@1335 | 13 | * accompanied this code). |
cfang@1335 | 14 | * |
cfang@1335 | 15 | * You should have received a copy of the GNU General Public License version |
cfang@1335 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
cfang@1335 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cfang@1335 | 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. |
cfang@1335 | 22 | */ |
cfang@1335 | 23 | |
cfang@1335 | 24 | /** |
cfang@1335 | 25 | * @test |
cfang@1335 | 26 | * @bug 6833129 |
cfang@1335 | 27 | * @summary Object.clone() and Arrays.copyOf ignore coping with -XX:+DeoptimizeALot |
cfang@1431 | 28 | * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+DeoptimizeALot Test |
cfang@1335 | 29 | */ |
cfang@1335 | 30 | |
cfang@1335 | 31 | public class Test{ |
cfang@1335 | 32 | public static void init(int src[]) { |
cfang@1335 | 33 | for (int i =0; i<src.length; i++) { |
cfang@1335 | 34 | src[i] = i; |
cfang@1335 | 35 | } |
cfang@1335 | 36 | } |
cfang@1335 | 37 | |
cfang@1335 | 38 | public static void clone_and_verify(int src[]) { |
cfang@1335 | 39 | for (int i = 0; i < src.length; i++) { |
cfang@1335 | 40 | int [] src_clone = src.clone(); |
cfang@1335 | 41 | if (src[i] != src_clone[i]) { |
cfang@1335 | 42 | System.out.println("Error: allocated but not copied: "); |
cfang@1335 | 43 | for( int j =0; j < src_clone.length; j++) |
cfang@1335 | 44 | System.out.print(" " + src_clone[j]); |
cfang@1335 | 45 | System.out.println(); |
cfang@1335 | 46 | System.exit(97); |
cfang@1335 | 47 | } |
cfang@1335 | 48 | } |
cfang@1335 | 49 | } |
cfang@1335 | 50 | |
cfang@1335 | 51 | public static void test() { |
cfang@1335 | 52 | int[] src = new int[34]; |
cfang@1335 | 53 | init(src); |
cfang@1335 | 54 | clone_and_verify(src); |
cfang@1335 | 55 | } |
cfang@1335 | 56 | |
cfang@1335 | 57 | public static void main(String[] args) { |
cfang@1335 | 58 | for (int i=0; i< 20000; i++) { |
cfang@1335 | 59 | test(); |
cfang@1335 | 60 | } |
cfang@1335 | 61 | } |
cfang@1335 | 62 | } |