Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/5091921/Test6992759.java
32285 views
/*1* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/**25* @test26* @bug 699275927* @summary Bad code generated for integer <= comparison, fails for Integer.MAX_VALUE28*29* @run main/timeout=240 Test699275930*/3132public class Test6992759 {3334static final int N_TESTS = 1000000000;3536public static void main(String[] args) throws Exception {3738/*39* If MAX_VALUE is changed to MAX_VALUE - 1 below, the test passes40* because (apparently) bad code is only generated when comparing41* <= MAX_VALUE in the doTest method.42*/43Test6992759 test = new Test6992759();44for (int i = 0; i < N_TESTS; i += 1) {45test.doTest(10, Integer.MAX_VALUE, i);46//test.doTest(10, Integer.MAX_VALUE - 1, i);47}48System.out.println("No failure");49}5051void doTest(int expected, int max, int i) {52int counted;53for (counted = 0;54(counted <= max) && (counted < expected);55counted += 1) {56}57if (counted != expected) {58throw new RuntimeException("Failed test iteration=" + i +59" max=" + max +60" counted=" + counted +61" expected=" + expected);62}63}64}65666768