1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/lambda/MethodReference52.java Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,39 @@ 1.4 +/* 1.5 + * @test /nodynamiccopyright/ 1.6 + * @bug 8003280 1.7 + * @summary Add lambda tests 1.8 + * special cases of method references (getClass()/Array.clone()) not handled properly 1.9 + * @compile/fail/ref=MethodReference52.out -XDrawDiagnostics MethodReference52.java 1.10 + */ 1.11 +import java.util.*; 1.12 + 1.13 +class MethodReference52 { 1.14 + 1.15 + interface Clone1 { 1.16 + int[] m(); 1.17 + } 1.18 + 1.19 + interface Clone2 { 1.20 + Object m(); 1.21 + } 1.22 + 1.23 + interface WrongClone { 1.24 + long[] m(); 1.25 + } 1.26 + 1.27 + interface GetClass { 1.28 + Class<? extends List> m(); 1.29 + } 1.30 + 1.31 + interface WrongGetClass { 1.32 + Class<List<String>> m(); 1.33 + } 1.34 + 1.35 + void test(int[] iarr, List<String> ls) { 1.36 + Clone1 c1 = iarr::clone; //ok 1.37 + Clone2 c2 = iarr::clone; //ok - type more generic 1.38 + WrongClone c3 = iarr::clone; //bad return type 1.39 + GetClass c4 = ls::getClass; //ok 1.40 + WrongGetClass c5 = ls::getClass; //bad return type 1.41 + } 1.42 +}