242
|
1 |
/*
|
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
|
3 |
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
|
4 |
*
|
|
5 |
*
|
|
6 |
*
|
|
7 |
*
|
|
8 |
*
|
|
9 |
*
|
|
10 |
*
|
|
11 |
*
|
|
12 |
*
|
|
13 |
*
|
|
14 |
*
|
|
15 |
*
|
|
16 |
*
|
|
17 |
*
|
|
18 |
*
|
|
19 |
*
|
|
20 |
*
|
|
21 |
*
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 6659207
|
|
27 |
* @summary access violation in CompilerThread0
|
|
28 |
*/
|
|
29 |
|
|
30 |
public class Test {
|
|
31 |
static int[] array = new int[12];
|
|
32 |
|
|
33 |
static int index(int i) {
|
|
34 |
if (i == 0) return 0;
|
|
35 |
for (int n = 0; n < array.length; n++)
|
|
36 |
if (i < array[n]) return n;
|
|
37 |
return -1;
|
|
38 |
}
|
|
39 |
|
|
40 |
static int test(int i) {
|
|
41 |
int result = 0;
|
|
42 |
i = index(i);
|
|
43 |
if (i >= 0)
|
|
44 |
if (array[i] != 0)
|
|
45 |
result++;
|
|
46 |
|
|
47 |
if (i != -1)
|
|
48 |
array[i]++;
|
|
49 |
|
|
50 |
return result;
|
|
51 |
}
|
|
52 |
|
|
53 |
public static void main(String[] args) {
|
|
54 |
int total = 0;
|
|
55 |
for (int i = 0; i < 100000; i++) {
|
|
56 |
total += test(10);
|
|
57 |
}
|
|
58 |
System.out.println(total);
|
|
59 |
}
|
|
60 |
}
|