test/compiler/6795161/Test.java

Thu, 20 Oct 2011 10:32:37 -0700

author
katleman
date
Thu, 20 Oct 2011 10:32:37 -0700
changeset 3191
3170e4044f2d
parent 2755
11427f216063
child 4684
7369298bec7e
permissions
-rw-r--r--

Added tag jdk8-b10 for changeset d815de2e85e5

kvn@1000 1 /*
dholmes@2755 2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
kvn@1000 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
kvn@1000 4 *
kvn@1000 5 * This code is free software; you can redistribute it and/or modify it
kvn@1000 6 * under the terms of the GNU General Public License version 2 only, as
kvn@1000 7 * published by the Free Software Foundation.
kvn@1000 8 *
kvn@1000 9 * This code is distributed in the hope that it will be useful, but WITHOUT
kvn@1000 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kvn@1000 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kvn@1000 12 * version 2 for more details (a copy is included in the LICENSE file that
kvn@1000 13 * accompanied this code).
kvn@1000 14 *
kvn@1000 15 * You should have received a copy of the GNU General Public License version
kvn@1000 16 * 2 along with this work; if not, write to the Free Software Foundation,
kvn@1000 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
kvn@1000 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
kvn@1000 22 *
kvn@1000 23 */
kvn@1000 24
kvn@1000 25 /*
kvn@1000 26 * @test
kvn@1000 27 * @bug 6795161
kvn@1000 28 * @summary Escape analysis leads to data corruption
dholmes@2755 29 * @run main/othervm -server -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:CompileOnly=Test -XX:+DoEscapeAnalysis Test
kvn@1000 30 */
kvn@1000 31
kvn@1000 32 class Test_Class_1 {
kvn@1000 33 static String var_1;
kvn@1000 34
kvn@1000 35 static void badFunc(int size)
kvn@1000 36 {
kvn@1000 37 try {
kvn@1000 38 for (int i = 0; i < 1; (new byte[size-i])[0] = 0, i++) {}
kvn@1000 39 } catch (Exception e) {
kvn@1000 40 // don't comment it out, it will lead to correct results ;)
kvn@1000 41 //System.out.println("Got exception: " + e);
kvn@1000 42 }
kvn@1000 43 }
kvn@1000 44 }
kvn@1000 45
kvn@1000 46 public class Test {
kvn@1000 47 static String var_1_copy = Test_Class_1.var_1;
kvn@1000 48
kvn@1000 49 static byte var_check;
kvn@1000 50
kvn@1000 51 public static void main(String[] args)
kvn@1000 52 {
kvn@1000 53 var_check = 1;
kvn@1000 54
kvn@1000 55 Test_Class_1.badFunc(-1);
kvn@1000 56
kvn@1000 57 System.out.println("EATester.var_check = " + Test.var_check + " (expected 1)\n");
kvn@1000 58 }
kvn@1000 59 }
kvn@1000 60

mercurial