author | duke |
Wed, 05 Jul 2017 22:24:41 +0200 | |
changeset 41867 | d62173b931bf |
parent 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
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 | 28 |
* |
29 |
* @run main/othervm -Xcomp |
|
30 |
* -XX:CompileCommand=compileonly,compiler.inlining.InlineDefaultMethod1::test |
|
31 |
* -XX:CompileCommand=compileonly,compiler.inlining.InlineDefaultMethod1$I1::m |
|
32 |
* -XX:CompileCommand=compileonly,compiler.inlining.InlineDefaultMethod1$I2::m |
|
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 | 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 | 39 |
interface I1 { |
40 |
default public int m() { return 0; } |
|
41 |
} |
|
42 |
||
43 |
interface I2 extends I1 { |
|
44 |
default public int m() { return 1; } |
|
45 |
} |
|
46 |
||
47 |
static abstract class A implements I1 { |
|
48 |
} |
|
49 |
||
50 |
static class B extends A implements I2 { |
|
51 |
} |
|
52 |
||
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 |
} |