Thu, 11 Apr 2013 09:39:57 -0700
Added tag jdk8-b85 for changeset 42fe530cd478
kvn@2877 | 1 | /* |
kvn@2877 | 2 | * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
kvn@2877 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
kvn@2877 | 4 | * |
kvn@2877 | 5 | * This code is free software; you can redistribute it and/or modify it |
kvn@2877 | 6 | * under the terms of the GNU General Public License version 2 only, as |
kvn@2877 | 7 | * published by the Free Software Foundation. |
kvn@2877 | 8 | * |
kvn@2877 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
kvn@2877 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
kvn@2877 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
kvn@2877 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
kvn@2877 | 13 | * accompanied this code). |
kvn@2877 | 14 | * |
kvn@2877 | 15 | * You should have received a copy of the GNU General Public License version |
kvn@2877 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
kvn@2877 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
kvn@2877 | 18 | * |
kvn@2877 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
kvn@2877 | 20 | * or visit www.oracle.com if you need additional information or have any |
kvn@2877 | 21 | * questions. |
kvn@2877 | 22 | * |
kvn@2877 | 23 | */ |
kvn@2877 | 24 | |
kvn@2877 | 25 | /** |
kvn@2877 | 26 | * @test |
kvn@2877 | 27 | * @bug 7005594 |
kvn@2877 | 28 | * @summary Array overflow not handled correctly with loop optimzations |
kvn@2877 | 29 | * |
kvn@2918 | 30 | * @run shell Test7005594.sh |
kvn@2877 | 31 | */ |
kvn@2877 | 32 | |
kvn@2877 | 33 | public class Test7005594 { |
kvn@2877 | 34 | |
kvn@2877 | 35 | static int test(byte a[]){ |
kvn@2877 | 36 | int result=0; |
kvn@2877 | 37 | for( int i=0; i<a.length; i+=((0x7fffffff>>1)+1) ){ |
kvn@2877 | 38 | result += a[i]; |
kvn@2877 | 39 | } |
kvn@2877 | 40 | return result; |
kvn@2877 | 41 | } |
kvn@2877 | 42 | |
kvn@2877 | 43 | public static void main(String [] args){ |
kvn@2877 | 44 | byte a[]=new byte[(0x7fffffff>>1)+2]; |
kvn@2877 | 45 | int result = 0; |
kvn@2877 | 46 | try { |
kvn@2877 | 47 | result = test(a); |
kvn@2877 | 48 | } catch (ArrayIndexOutOfBoundsException e) { |
kvn@2877 | 49 | e.printStackTrace(System.out); |
kvn@2877 | 50 | System.out.println("Passed"); |
kvn@2877 | 51 | System.exit(95); |
kvn@2877 | 52 | } |
kvn@2877 | 53 | System.out.println(result); |
kvn@2877 | 54 | System.out.println("FAILED"); |
kvn@2877 | 55 | System.exit(97); |
kvn@2877 | 56 | } |
kvn@2877 | 57 | |
kvn@2877 | 58 | } |
kvn@2877 | 59 |