aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 8026231 aoqi@0: * @summary Look at 'static' flag when checking method references aoqi@0: * @compile/fail/ref=MethodReference73.out -XDrawDiagnostics MethodReference73.java aoqi@0: */ aoqi@0: aoqi@0: public class MethodReference73 { aoqi@0: aoqi@0: interface SAM { aoqi@0: void m(MethodReference73 rec, String x); aoqi@0: } aoqi@0: aoqi@0: void m1(MethodReference73 rec, String x) {} aoqi@0: static void m1(MethodReference73 rec, Object x) {} aoqi@0: void m1(String x) {} aoqi@0: aoqi@0: static void m2(MethodReference73 rec, String x) {} aoqi@0: void m2(Object x) {} aoqi@0: static void m2(String x) {} aoqi@0: aoqi@0: static void m3(MethodReference73 rec, String x) {} aoqi@0: void m3(String x) {} aoqi@0: aoqi@0: void m4(MethodReference73 rec, String x) {} aoqi@0: static void m4(MethodReference73 rec, Object x) {} aoqi@0: static void m4(String x) {} aoqi@0: void m4(Object x) {} aoqi@0: aoqi@0: static void m5(MethodReference73 rec, String x) {} aoqi@0: static void m5(String x) {} aoqi@0: aoqi@0: static void m6(MethodReference73 rec, String x) {} aoqi@0: void m6(String x, int i) {} aoqi@0: aoqi@0: void m7(MethodReference73 rec, String x) {} aoqi@0: void m7(String x) {} aoqi@0: aoqi@0: static void m8(MethodReference73 rec, String x, int i) {} aoqi@0: void m8(String x) {} aoqi@0: aoqi@0: void m9(MethodReference73 rec, String x) {} aoqi@0: static void m9(MethodReference73 rec, Object x) {} aoqi@0: static void m9(String x) {} aoqi@0: aoqi@0: void m10(MethodReference73 rec, String x) {} aoqi@0: static void m10(MethodReference73 rec, Object x) {} aoqi@0: void m10(String x, int i) {} aoqi@0: aoqi@0: void m11(MethodReference73 rec, String x) {} aoqi@0: void m11(Object x) {} aoqi@0: static void m11(String x) {} aoqi@0: aoqi@0: static void m12(MethodReference73 rec, String x, int i) {} aoqi@0: void m12(Object x) {} aoqi@0: static void m12(String x) {} aoqi@0: aoqi@0: void m13(MethodReference73 rec, String x) {} aoqi@0: void m13(String x, int i) {} aoqi@0: aoqi@0: static void m14(MethodReference73 rec, String x, int i) {} aoqi@0: static void m14(String x) {} aoqi@0: aoqi@0: void m15(MethodReference73 rec, String x) {} aoqi@0: static void m15(String x) {} aoqi@0: aoqi@0: static void m16(MethodReference73 rec, String x, int i) {} aoqi@0: void m16(String x, int i) {} aoqi@0: aoqi@0: /** For method references with a type selector two searches are performed. aoqi@0: * Each of them may yield one of the following results: aoqi@0: * I) a good match aoqi@0: * II) a bad match more specific than a good match aoqi@0: * III) a bad match with no good matches aoqi@0: * IV) no applicable method found aoqi@0: * aoqi@0: * Whether a match is considered to be good or not depends on the staticness aoqi@0: * of the matched method. The expected result of the first search is a static aoqi@0: * method. The expected result of the second search is an instance method. aoqi@0: * aoqi@0: * If the most specific method has the wrong staticness but there is an aoqi@0: * applicable method with the right staticness then we have the (II) case. aoqi@0: * The (III) case is reserved for those cases when the most specific method aoqi@0: * has the wrong staticness but there is no applicable method with the right aoqi@0: * staticness. aoqi@0: */ aoqi@0: aoqi@0: static void test() { aoqi@0: SAM s1 = MethodReference73::m1; //(II, I) ambiguous aoqi@0: SAM s2 = MethodReference73::m2; //(I, II) ambiguous aoqi@0: SAM s3 = MethodReference73::m3; //(I, I) ambiguous aoqi@0: SAM s4 = MethodReference73::m4; //(II, II) ambiguous aoqi@0: aoqi@0: SAM s5 = MethodReference73::m5; //(I, III) first search's result gets selected aoqi@0: SAM s6 = MethodReference73::m6; //(I, IV) first search's result gets selected aoqi@0: aoqi@0: SAM s7 = MethodReference73::m7; //(III, I) second search's result gets selected aoqi@0: SAM s8 = MethodReference73::m8; //(IV, I) second search's result gets selected aoqi@0: aoqi@0: SAM s9 = MethodReference73::m9; //(II, III) method matched by first search has the wrong staticness aoqi@0: SAM s10 = MethodReference73::m10; //(II, IV) method matched by first search has the wrong staticness aoqi@0: SAM s11 = MethodReference73::m11; //(III, II) method matched by second search has the wrong staticness aoqi@0: SAM s12 = MethodReference73::m12; //(IV, II) method matched by second search has the wrong staticness aoqi@0: SAM s13 = MethodReference73::m13; //(III, IV) method matched by first search has the wrong staticness aoqi@0: SAM s14 = MethodReference73::m14; //(IV, III) method matched by second search has the wrong staticness aoqi@0: SAM s15 = MethodReference73::m15; //(III, III) method matched by first search has the wrong staticness aoqi@0: aoqi@0: SAM s16 = MethodReference73::m16; //(IV, IV) incompatible types, invalid method reference aoqi@0: } aoqi@0: }