jdk
69 строк · 2.3 Кб
1/*
2* Copyright (c) 2022, Red Hat, Inc. All rights reserved.
3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*
5* This code is free software; you can redistribute it and/or modify it
6* under the terms of the GNU General Public License version 2 only, as
7* published by the Free Software Foundation.
8*
9* This code is distributed in the hope that it will be useful, but WITHOUT
10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12* version 2 for more details (a copy is included in the LICENSE file that
13* accompanied this code).
14*
15* You should have received a copy of the GNU General Public License version
16* 2 along with this work; if not, write to the Free Software Foundation,
17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18*
19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20* or visit www.oracle.com if you need additional information or have any
21* questions.
22*/
23
24/*
25* @test
26* @bug 8291665
27* @summary C2: assert compiling SSLEngineInputRecord::decodeInputRecord
28* @run main/othervm -Xbatch TestNewArrayOutsideLoopValidLengthTestInLoop
29*/
30
31import java.util.Arrays;32
33public class TestNewArrayOutsideLoopValidLengthTestInLoop {34private static volatile int barrier;35
36public static void main(String[] args) {37boolean[] allFalse = new boolean[100];38boolean[] allTrue = new boolean[100];39Arrays.fill(allTrue, true);40for (int i = 0; i < 20_000; i++) {41test1(allFalse, allFalse, true);42test1(allTrue, allFalse, true);43test1(allFalse, allTrue, true);44test1(allFalse, allFalse, false);45}46}47
48private static int[] test1(boolean[] flags1, boolean[] flags2, boolean flag) {49for (int i = 1; i < 100; i *= 2) {50boolean f = false;51int j = i;52if (flags1[i]) {53barrier = 1;54f = true;55j = i / 2;56}57if (flag) {58barrier = 1;59}60if (f) {61return new int[j];62}63if (flags2[i]) {64return new int[j];65}66}67return null;68}69}
70