hotspot/test/compiler/inlining/DefaultAndConcreteMethodsCHA.java
author dsamersoff
Sun, 01 May 2016 12:47:00 +0300
changeset 38152 80e5da81fb2c
parent 22514 7f26d1aea7a4
child 40059 c2304140ed64
permissions -rw-r--r--
8154258: [TESTBUG] Various serviceability tests fail compilation Summary: Replace sun.misc.Unsafe with jdk.internal.misc.Unsafe Reviewed-by: chegar, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22514
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     1
/*
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     4
 *
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     8
 *
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    14
 *
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    18
 *
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    21
 * questions.
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    22
 */
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    23
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    24
/**
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    25
 * @test
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    26
 * @bug 8031695
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    27
 * @summary CHA ignores default methods during analysis leading to incorrect code generation
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    28
 *
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    29
 * @run main/othervm -Xbatch DefaultAndConcreteMethodsCHA
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    30
 */
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    31
interface I {
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    32
    default int m() { return 0; }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    33
}
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    34
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    35
class A implements I {}
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    36
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    37
class C extends A { }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    38
class D extends A { public int m() { return 1; } }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    39
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    40
public class DefaultAndConcreteMethodsCHA {
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    41
    public static int test(A obj) {
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    42
        return obj.m();
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    43
    }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    44
    public static void main(String[] args) {
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    45
        for (int i = 0; i < 10000; i++) {
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    46
            int idC = test(new C());
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    47
            if (idC != 0) {
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    48
                throw new Error("C.m didn't invoke I.m: id "+idC);
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    49
            }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    50
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    51
            int idD = test(new D());
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    52
            if (idD != 1) {
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    53
                throw new Error("D.m didn't invoke D.m: id "+idD);
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    54
            }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    55
        }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    56
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    57
    }
7f26d1aea7a4 8031695: CHA ignores default methods during analysis leading to incorrect code generation
vlivanov
parents:
diff changeset
    58
}