Thu, 11 Apr 2013 09:39:57 -0700
Added tag jdk8-b85 for changeset 42fe530cd478
kvn@2877 | 1 | /* |
drchase@4618 | 2 | * Copyright (c) 2011, 2013, 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 6992759 |
kvn@2877 | 28 | * @summary Bad code generated for integer <= comparison, fails for Integer.MAX_VALUE |
kvn@2877 | 29 | * |
drchase@4618 | 30 | * @run main/timeout=240 Test6992759 |
kvn@2877 | 31 | */ |
kvn@2877 | 32 | |
kvn@2877 | 33 | public class Test6992759 { |
kvn@2877 | 34 | |
kvn@2877 | 35 | static final int N_TESTS = 1000000000; |
kvn@2877 | 36 | |
kvn@2877 | 37 | public static void main(String[] args) throws Exception { |
kvn@2877 | 38 | |
kvn@2877 | 39 | /* |
kvn@2877 | 40 | * If MAX_VALUE is changed to MAX_VALUE - 1 below, the test passes |
kvn@2877 | 41 | * because (apparently) bad code is only generated when comparing |
kvn@2877 | 42 | * <= MAX_VALUE in the doTest method. |
kvn@2877 | 43 | */ |
kvn@2877 | 44 | Test6992759 test = new Test6992759(); |
kvn@2877 | 45 | for (int i = 0; i < N_TESTS; i += 1) { |
kvn@2877 | 46 | test.doTest(10, Integer.MAX_VALUE, i); |
kvn@2877 | 47 | //test.doTest(10, Integer.MAX_VALUE - 1, i); |
kvn@2877 | 48 | } |
kvn@2877 | 49 | System.out.println("No failure"); |
kvn@2877 | 50 | } |
kvn@2877 | 51 | |
kvn@2877 | 52 | void doTest(int expected, int max, int i) { |
kvn@2877 | 53 | int counted; |
kvn@2877 | 54 | for (counted = 0; |
kvn@2877 | 55 | (counted <= max) && (counted < expected); |
kvn@2877 | 56 | counted += 1) { |
kvn@2877 | 57 | } |
kvn@2877 | 58 | if (counted != expected) { |
kvn@2877 | 59 | throw new RuntimeException("Failed test iteration=" + i + |
kvn@2877 | 60 | " max=" + max + |
kvn@2877 | 61 | " counted=" + counted + |
kvn@2877 | 62 | " expected=" + expected); |
kvn@2877 | 63 | } |
kvn@2877 | 64 | } |
kvn@2877 | 65 | } |
kvn@2877 | 66 |