1 /*
2 * Copyright (c) 2020, Red Hat, Inc. All rights reserved.
3 * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /**
26 * @test
27 * @bug 8253566
28 * @bug 8295414
29 * @summary clazz.isAssignableFrom will return false for interface implementors
30 * @requires vm.compiler2.enabled
31 *
32 * @run main/othervm -XX:-BackgroundCompilation TestSubTypeCheckMacroTrichotomy
33 * @run main/othervm -XX:-BackgroundCompilation
34 * -XX:+IgnoreUnrecognizedVMOptions -XX:+StressReflectiveCode
35 * -XX:+UnlockDiagnosticVMOptions -XX:+ExpandSubTypeCheckAtParseTime
36 * -XX:-TieredCompilation -XX:CompileThreshold=100 TestSubTypeCheckMacroTrichotomy
37 *
38 */
39
40 public class TestSubTypeCheckMacroTrichotomy {
41 public static void main(String[] args) {
42 for (int i = 0; i < 20_000; i++) {
43 final int res1 = test(A.class, B.class);
44 final int res2 = test(B.class, A.class);
45 final int res3 = test(A.class, C.class);
46 if (res1 != 0 || res2 != 1 || res3 != 0) {
47 throw new RuntimeException("test(A, B) = " + res1 + " test(B, A) = " + res2 + " test(A, C) = " + res3);
48 }
49 }
50 }
51
52 private static int test(Class<?> c1, Class<?> c2) {
53 if (c1 == null) {
54 }
55 if (c2 == null) {
|
1 /*
2 * Copyright (c) 2020, Red Hat, Inc. All rights reserved.
3 * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 /**
26 * @test
27 * @bug 8253566
28 * @bug 8295414
29 * @summary clazz.isAssignableFrom will return false for interface implementors
30 * @requires vm.compiler2.enabled
31 *
32 * @run main/othervm -XX:-BackgroundCompilation TestSubTypeCheckMacroTrichotomy
33 * @run main/othervm -XX:-BackgroundCompilation
34 * -XX:+IgnoreUnrecognizedVMOptions -XX:+StressReflectiveCode
35 * -XX:-TieredCompilation -XX:CompileThreshold=100 TestSubTypeCheckMacroTrichotomy
36 *
37 */
38
39 public class TestSubTypeCheckMacroTrichotomy {
40 public static void main(String[] args) {
41 for (int i = 0; i < 20_000; i++) {
42 final int res1 = test(A.class, B.class);
43 final int res2 = test(B.class, A.class);
44 final int res3 = test(A.class, C.class);
45 if (res1 != 0 || res2 != 1 || res3 != 0) {
46 throw new RuntimeException("test(A, B) = " + res1 + " test(B, A) = " + res2 + " test(A, C) = " + res3);
47 }
48 }
49 }
50
51 private static int test(Class<?> c1, Class<?> c2) {
52 if (c1 == null) {
53 }
54 if (c2 == null) {
|