1 /* 2 * @test /nodynamiccopyright/ 3 * @bug 8003280 4 * @summary Add lambda tests 5 * This is negative test for wrong parameter/return type in method references 6 * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java 7 */ 8 9 public class MethodRef_neg { 10 m(Integer i)11 static interface A {void m(Integer i);} 12 m(String s)13 static interface B {void m(String s);} 14 m()15 static interface C {Integer m();} 16 m()17 static interface D {String m();} 18 19 bar(int x)20 static void bar(int x) { } 21 foo()22 int foo() { 23 return 5; 24 } 25 make()26 static void make() { } 27 method()28 void method() { 29 A a = MethodRef_neg::bar; //boxing on parameter type is ok 30 B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int 31 C c = this::foo; //boxing on return type is ok 32 D d = this::foo; //wrong return type, required: String, actual: int 33 a = MethodRef_neg::make; //missing parameter 34 c = MethodRef_neg::make; //missing return type 35 } 36 } 37