Mercurial > hg > truffle
comparison test/runtime/lambda-features/InvokespecialInterface.java @ 20576:90257dfad6e3
8043275: 8u40 backport: Fix interface initialization for default methods.
Reviewed-by: dcubed, coleenp
author | acorn |
---|---|
date | Fri, 24 Oct 2014 12:29:08 -0700 |
parents | 10c9507f544a |
children |
comparison
equal
deleted
inserted
replaced
20570:1bd99e1dc168 | 20576:90257dfad6e3 |
---|---|
31 * @run main/othervm -XX:+StressRewriter InvokespecialInterface | 31 * @run main/othervm -XX:+StressRewriter InvokespecialInterface |
32 */ | 32 */ |
33 import java.util.function.*; | 33 import java.util.function.*; |
34 import java.util.*; | 34 import java.util.*; |
35 | 35 |
36 public class InvokespecialInterface { | |
36 interface I { | 37 interface I { |
37 default void imethod() { System.out.println("I::imethod"); } | 38 default void imethod() { System.out.println("I::imethod"); } |
38 } | 39 } |
39 | 40 |
40 class C implements I { | 41 static class C implements I { |
41 public void foo() { I.super.imethod(); } // invokespecial InterfaceMethod | 42 public void foo() { I.super.imethod(); } // invokespecial InterfaceMethod |
42 public void bar() { I i = this; i.imethod(); } // invokeinterface same | 43 public void bar() { I i = this; i.imethod(); } // invokeinterface same |
43 public void doSomeInvokedynamic() { | 44 public void doSomeInvokedynamic() { |
44 String str = "world"; | 45 String str = "world"; |
45 Supplier<String> foo = ()->"hello, "+str; | 46 Supplier<String> foo = ()->"hello, "+str; |
46 String res = foo.get(); | 47 String res = foo.get(); |
47 System.out.println(res); | 48 System.out.println(res); |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 public class InvokespecialInterface { | |
52 public static void main(java.lang.String[] unused) { | 52 public static void main(java.lang.String[] unused) { |
53 // need to create C and call I::foo() | 53 // need to create C and call I::foo() |
54 C c = new C(); | 54 C c = new C(); |
55 c.foo(); | 55 c.foo(); |
56 c.bar(); | 56 c.bar(); |