1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/VoidCompatibility.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,26 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 8003280 1.7 + * @summary Add lambda tests 1.8 + * check that that void compatibility affects overloading as expected 1.9 + * @compile VoidCompatibility.java 1.10 + */ 1.11 +class VoidCompatibility { 1.12 + 1.13 + interface Runnable { void run(); } //1 1.14 + interface Thunk<T> { T get(); } //2 1.15 + 1.16 + void schedule(Runnable r) { } 1.17 + void schedule(Thunk<?> t) { } 1.18 + 1.19 + void test() { 1.20 + schedule(() -> System.setProperty("done", "true")); //non-void most specific 1.21 + schedule(() -> { System.setProperty("done", "true"); }); //1 1.22 + schedule(() -> { return System.setProperty("done", "true"); }); //2 1.23 + schedule(() -> System.out.println("done")); //1 1.24 + schedule(() -> { System.out.println("done"); }); //1 1.25 + schedule(Thread::yield); //1 1.26 + schedule(Thread::getAllStackTraces); //non-void most specific 1.27 + schedule(Thread::interrupted); //1 (most specific) 1.28 + } 1.29 +}