hotspot/test/compiler/6659207/Test.java
author xdono
Wed, 02 Jul 2008 12:55:16 -0700
changeset 670 ddf3e9583f2f
parent 603 0e934fae2fc2
child 5547 f4b087cbb361
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
242
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 603
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
242
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
     4
 *
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
     7
 * published by the Free Software Foundation.
242
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
     8
 *
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    13
 * accompanied this code).
242
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    14
 *
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
242
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    18
 *
603
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
0e934fae2fc2 6706604: Copyright headers need to be changed to GPL.
kamg
parents: 242
diff changeset
    21
 * have any questions.
242
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    22
 *
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    23
 */
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    24
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    25
/*
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    26
 * @test
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    27
 * @bug 6659207
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    28
 * @summary access violation in CompilerThread0
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    29
 */
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    30
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    31
public class Test {
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    32
    static int[] array = new int[12];
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    33
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    34
    static int index(int i) {
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    35
        if (i == 0) return 0;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    36
        for (int n = 0; n < array.length; n++)
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    37
            if (i < array[n]) return n;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    38
        return -1;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    39
    }
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    40
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    41
    static int test(int i) {
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    42
        int result = 0;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    43
        i = index(i);
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    44
        if (i >= 0)
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    45
            if (array[i] != 0)
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    46
                result++;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    47
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    48
        if (i != -1)
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    49
            array[i]++;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    50
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    51
        return result;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    52
    }
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    53
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    54
    public static void main(String[] args) {
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    55
        int total = 0;
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    56
        for (int i = 0; i < 100000; i++) {
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    57
            total += test(10);
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    58
        }
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    59
        System.out.println(total);
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    60
    }
f4a8c30a53b0 6659207: access violation in CompilerThread0
never
parents:
diff changeset
    61
}