annotate test/compiler/6659207/Test.java @ 177:2a8ec427fbe1

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