2012-11-17 19:01:03 +00:00
|
|
|
/*
|
|
|
|
* @test /nodynamiccopyright/
|
|
|
|
* @bug 8003280
|
|
|
|
* @summary Add lambda tests
|
2022-11-30 00:42:40 +00:00
|
|
|
* check that void compatibility affects overloading as expected
|
2013-01-21 20:13:56 +00:00
|
|
|
* @compile VoidCompatibility.java
|
2012-11-17 19:01:03 +00:00
|
|
|
*/
|
|
|
|
class VoidCompatibility {
|
|
|
|
|
|
|
|
interface Runnable { void run(); } //1
|
|
|
|
interface Thunk<T> { T get(); } //2
|
|
|
|
|
|
|
|
void schedule(Runnable r) { }
|
|
|
|
void schedule(Thunk<?> t) { }
|
|
|
|
|
|
|
|
void test() {
|
2013-01-21 20:13:56 +00:00
|
|
|
schedule(() -> System.setProperty("done", "true")); //non-void most specific
|
2012-11-17 19:01:03 +00:00
|
|
|
schedule(() -> { System.setProperty("done", "true"); }); //1
|
|
|
|
schedule(() -> { return System.setProperty("done", "true"); }); //2
|
|
|
|
schedule(() -> System.out.println("done")); //1
|
|
|
|
schedule(() -> { System.out.println("done"); }); //1
|
|
|
|
schedule(Thread::yield); //1
|
2013-01-21 20:13:56 +00:00
|
|
|
schedule(Thread::getAllStackTraces); //non-void most specific
|
2012-11-17 19:01:03 +00:00
|
|
|
schedule(Thread::interrupted); //1 (most specific)
|
|
|
|
}
|
|
|
|
}
|