1 /*
2 * Copyright (c) 2022, Red Hat, Inc. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * bug 8280885
27 * @summary Shenandoah: Some tests failed with "EA: missing allocation reference path"
28 * @requires vm.gc.Shenandoah
29 *
30 * @run main/othervm -XX:-BackgroundCompilation -XX:+UseShenandoahGC -XX:+UnlockExperimentalVMOptions -XX:ShenandoahGCMode=iu
31 * -XX:CompileCommand=dontinline,TestUnexpectedIUBarrierEA::notInlined TestUnexpectedIUBarrierEA
32 */
33
34 public class TestUnexpectedIUBarrierEA {
35
36 private static Object field;
37
38 public static void main(String[] args) {
39 for (int i = 0; i < 20_000; i++) {
40 test(false);
41 }
42 }
43
44 private static void test(boolean flag) {
45 A a = new A();
46 B b = new B();
47 b.field = a;
48 notInlined();
49 Object o = b.field;
50 if (!(o instanceof A)) {
51
52 }
53 C c = new C();
54 c.field = o;
55 if (flag) {
56 field = c.field;
57 }
58 }
59
60 private static void notInlined() {
61
62 }
63
64 private static class A {
65 }
66
67 private static class B {
68 public Object field;
69 }
70
71 private static class C {
72 public Object field;
73 }
74 }