hotspot/test/compiler/inlining/InlineDefaultMethod1.java
author vlivanov
Tue, 04 Mar 2014 02:33:10 -0800
changeset 23194 e60d7409415b
child 40059 c2304140ed64
permissions -rw-r--r--
8036100: Default method returns true for a while, and then returns false Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23194
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     1
/*
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     4
 *
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     8
 *
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    14
 *
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    18
 *
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    21
 * questions.
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    22
 */
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    23
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    24
/*
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    25
 * @test
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    26
 * @bug 8036100
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    27
 * @summary Default method returns true for a while, and then returns false
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    28
 * @run main/othervm -Xcomp -XX:CompileOnly=InlineDefaultMethod1::test
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    29
 *                   -XX:CompileOnly=I1::m -XX:CompileOnly=I2::m
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    30
 *                   InlineDefaultMethod1
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    31
 */
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    32
interface I1 {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    33
    default public int m() { return 0; }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    34
}
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    35
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    36
interface I2 extends I1 {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    37
    default public int m() { return 1; }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    38
}
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    39
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    40
abstract class A implements I1 {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    41
}
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    42
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    43
class B extends A implements I2 {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    44
}
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    45
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    46
public class InlineDefaultMethod1 {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    47
    public static void test(A obj) {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    48
        int id = obj.m();
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    49
        if (id != 1) {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    50
            throw new AssertionError("Called wrong method: 1 != "+id);
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    51
        }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    52
    }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    53
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    54
    public static void main(String[] args) throws InterruptedException {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    55
        test(new B());
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    56
        System.out.println("TEST PASSED");
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    57
    }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    58
}