test/compiler/6659207/Test.java

Thu, 29 May 2008 14:06:30 -0400

author
kamg
date
Thu, 29 May 2008 14:06:30 -0400
changeset 612
2a8ec427fbe1
parent 504
8bb88f9877e5
child 631
d1605aabd0a1
permissions
-rw-r--r--

6706604: Copyright headers need to be changed to GPL.
Summary: Update the copyrights
Reviewed-by: ohair

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

mercurial