hotspot/test/compiler/inlining/InlineDefaultMethod1.java
author duke
Wed, 05 Jul 2017 22:24:41 +0200
changeset 41867 d62173b931bf
parent 40059 c2304140ed64
permissions -rw-r--r--
Merge
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
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    28
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    29
 * @run main/othervm -Xcomp
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    30
 *      -XX:CompileCommand=compileonly,compiler.inlining.InlineDefaultMethod1::test
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    31
 *      -XX:CompileCommand=compileonly,compiler.inlining.InlineDefaultMethod1$I1::m
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    32
 *      -XX:CompileCommand=compileonly,compiler.inlining.InlineDefaultMethod1$I2::m
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    33
 *      compiler.inlining.InlineDefaultMethod1
23194
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
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    36
package compiler.inlining;
23194
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    37
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    38
public class InlineDefaultMethod1 {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    39
    interface I1 {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    40
        default public int m() { return 0; }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    41
    }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    42
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    43
    interface I2 extends I1 {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    44
        default public int m() { return 1; }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    45
    }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    46
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    47
    static abstract class A implements I1 {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    48
    }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    49
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    50
    static class B extends A implements I2 {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    51
    }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    52
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23194
diff changeset
    53
23194
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    54
    public static void test(A obj) {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    55
        int id = obj.m();
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    56
        if (id != 1) {
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    57
            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
    58
        }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    59
    }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    60
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    61
    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
    62
        test(new B());
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    63
        System.out.println("TEST PASSED");
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    64
    }
e60d7409415b 8036100: Default method returns true for a while, and then returns false
vlivanov
parents:
diff changeset
    65
}