test/hotspot/jtreg/compiler/osr/TestRangeCheck.java
author iignatyev
Mon, 18 Feb 2019 09:31:07 -0800
changeset 53791 bec6c8739833
parent 47216 71c04702a3d5
permissions -rw-r--r--
8219157: vm/mlvm/mixed/stress/java/findDeadlock should be problem-listed only on mac Reviewed-by: thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26707
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     1
/*
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     4
 *
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     8
 *
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    14
 *
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    18
 *
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    21
 * questions.
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    22
 */
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    23
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    24
/*
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    25
 * @test TestRangeCheck
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    26
 * @bug 8054883
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    27
 * @summary Tests that range check is not skipped
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 26707
diff changeset
    28
 * @run main compiler.osr.TestRangeCheck
26707
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    29
 */
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    30
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 26707
diff changeset
    31
package compiler.osr;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 26707
diff changeset
    32
26707
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    33
public class TestRangeCheck {
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    34
    public static void main(String args[]) {
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    35
        try {
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    36
            test();
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    37
            throw new AssertionError("Expected ArrayIndexOutOfBoundsException was not thrown");
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    38
        } catch (ArrayIndexOutOfBoundsException e) {
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    39
            System.out.println("Expected ArrayIndexOutOfBoundsException was thrown");
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    40
        }
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    41
    }
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    42
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    43
    private static void test() {
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    44
        int arr[] = new int[1];
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    45
        int result = 1;
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    46
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    47
        // provoke OSR compilation
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    48
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    49
        }
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    50
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    51
        if (result > 0 && arr[~result] > 0) {
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    52
            arr[~result] = 0;
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    53
        }
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    54
    }
92f8c836b168 8057165: [TESTBUG] Need a test to cover JDK-8054883
iignatyev
parents:
diff changeset
    55
}