jdk

Форк
0
/
TestNewArrayOutsideLoopValidLengthTestInLoop.java 
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

31
import java.util.Arrays;
32

33
public class TestNewArrayOutsideLoopValidLengthTestInLoop {
34
    private static volatile int barrier;
35

36
    public static void main(String[] args) {
37
        boolean[] allFalse = new boolean[100];
38
        boolean[] allTrue = new boolean[100];
39
        Arrays.fill(allTrue, true);
40
        for (int i = 0; i < 20_000; i++) {
41
            test1(allFalse, allFalse, true);
42
            test1(allTrue, allFalse, true);
43
            test1(allFalse, allTrue, true);
44
            test1(allFalse, allFalse, false);
45
        }
46
    }
47

48
    private static int[] test1(boolean[] flags1, boolean[] flags2, boolean flag) {
49
        for (int i = 1; i < 100; i *= 2) {
50
            boolean f = false;
51
            int j = i;
52
            if (flags1[i]) {
53
                barrier = 1;
54
                f = true;
55
                j = i / 2;
56
            }
57
            if (flag) {
58
                barrier = 1;
59
            }
60
            if (f) {
61
                return new int[j];
62
            }
63
            if (flags2[i]) {
64
                return new int[j];
65
            }
66
        }
67
        return null;
68
    }
69
}
70

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.