/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 8378005 * @summary assert in proj_out when StressLongCountedLoop converts infinite loop to long counted loop nest * @run main ${test.main.class} * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:StressLongCountedLoop=1 * -XX:CompileCommand=compileonly,${test.main.class}::test ${test.main.class} */ package compiler.loopopts; public class TestStressLongCountedLoopInfiniteLoop { static int RANGE; public static void main(String[] args) { int[] a = new int[RANGE]; for (int i = 0; i < 10000; i++) { try { test(a, 0); } catch (ArrayIndexOutOfBoundsException e) { } } } static void test(int[] a, int invar) { // new Integer(0) works too, using MyInteger to avoid deprecation warnings. a[new MyInteger(0).v()] = 0; Object o; for (int i = 0; i < 1; i++) { o = 1; } // Infinite loop: j is always 0, 0 < 1 is always true. for (int j = 0; Integer.valueOf(j) < 1;) { j = 0; } } static class MyInteger { int v; MyInteger(int v) { this.v = v; } int v() { return Integer.valueOf(v); } } }