diff --git a/test/tools/javac/lambda/MostSpecific10.java b/test/tools/javac/lambda/MostSpecific10.java --- a/test/tools/javac/lambda/MostSpecific10.java +++ b/test/tools/javac/lambda/MostSpecific10.java @@ -25,9 +25,12 @@ * @test * @bug 8034223 * @summary Structural most-specific logic for lambdas, method refs, parens, and conditionals - * @compile MostSpecific10.java */ -class MostSpecific10 { +public class MostSpecific10 { + + public static void main(String[] args) { + new MostSpecific10().test(true); + } interface GetInt { int get(); @@ -38,7 +41,9 @@ } void m(GetInt getter) {} - void m(GetInteger getter) {} + void m(GetInteger getter) { + throw new RuntimeException("Less-specific method invocation: " + getter.getClass()); + } void test(boolean cond) { m(() -> 23); diff --git a/test/tools/javac/lambda/MostSpecific11.java b/test/tools/javac/lambda/MostSpecific11.java --- a/test/tools/javac/lambda/MostSpecific11.java +++ b/test/tools/javac/lambda/MostSpecific11.java @@ -25,14 +25,19 @@ * @test * @bug 8034223 * @summary Return type Object is not more specific than return type String - * @compile MostSpecific11.java */ -class MostSpecific11 { +public class MostSpecific11 { + + public static void main(String[] args) { + new MostSpecific11().test(); + } interface I { Object run(); } interface J { String run(); } - void m(I arg) {} + void m(I arg) { + throw new RuntimeException("Less-specific method invocation."); + } void m(J arg) {} void test() { diff --git a/test/tools/javac/lambda/MostSpecific15.java b/test/tools/javac/lambda/MostSpecific15.java --- a/test/tools/javac/lambda/MostSpecific15.java +++ b/test/tools/javac/lambda/MostSpecific15.java @@ -25,13 +25,18 @@ * @test * @bug 8143852 * @summary Rename functional interface method type parameters during most specific test - * @compile MostSpecific15.java */ -class MostSpecific15 { +public class MostSpecific15 { + public static void main(String[] args) { + new MostSpecific15().test(); + } + interface F1 { Object apply(X arg); } interface F2 { String apply(Y arg); } - static void m1(F1 f) {} + static void m1(F1 f) { + throw new RuntimeException("Less-specific method invocation."); + } static void m1(F2 f) {} static String foo(Object in) { return "a"; } diff --git a/test/tools/javac/lambda/MostSpecific17.java b/test/tools/javac/lambda/MostSpecific17.java --- a/test/tools/javac/lambda/MostSpecific17.java +++ b/test/tools/javac/lambda/MostSpecific17.java @@ -25,9 +25,12 @@ * @test * @bug 8143852 * @summary Rename functional interface method type parameters during most specific test - * @compile MostSpecific17.java */ -class MostSpecific17 { +public class MostSpecific17 { + + public static void main(String[] args) { + new MostSpecific17().test(); + } interface A {} interface B extends A {} @@ -35,7 +38,9 @@ interface F1 { A apply(Object arg); } interface F2 { B apply(Object arg); } - static void m1(F1 f) {} + static void m1(F1 f) { + throw new RuntimeException("Less-specific method invocation."); + } static void m1(F2 f) {} static B foo(Object in) { return null; } diff --git a/test/tools/javac/lambda/MostSpecific18.java b/test/tools/javac/lambda/MostSpecific18.java --- a/test/tools/javac/lambda/MostSpecific18.java +++ b/test/tools/javac/lambda/MostSpecific18.java @@ -25,13 +25,18 @@ * @test * @bug 8143852 * @summary Test that generic function interface method bounds are the same - * @compile MostSpecific18.java */ -class MostSpecific18 { +public class MostSpecific18 { + public static void main(String[] args) { + new MostSpecific18().test(); + } + interface F1 { Object apply(X arg); } interface F2 { String apply(Y arg); } - static void m1(F1 f) {} + static void m1(F1 f) { + throw new RuntimeException("Less-specific method invocation."); + } static void m1(F2 f) {} static String foo(Object in) { return "a"; } diff --git a/test/tools/javac/lambda/MostSpecific20.java b/test/tools/javac/lambda/MostSpecific20.java --- a/test/tools/javac/lambda/MostSpecific20.java +++ b/test/tools/javac/lambda/MostSpecific20.java @@ -25,13 +25,18 @@ * @test * @bug 8143852 * @summary Test that generic function interface method bounds are the same - * @compile MostSpecific20.java */ -class MostSpecific20 { +public class MostSpecific20 { + public static void main(String[] args) { + new MostSpecific20().test(); + } + interface F1 { > Object apply(X arg); } interface F2 { > String apply(Y arg); } - static void m1(F1 f) {} + static void m1(F1 f) { + throw new RuntimeException("Less-specific method invocation."); + } static void m1(F2 f) {} static String foo(Object in) { return "a"; } diff --git a/test/tools/javac/lambda/MostSpecific22.java b/test/tools/javac/lambda/MostSpecific22.java --- a/test/tools/javac/lambda/MostSpecific22.java +++ b/test/tools/javac/lambda/MostSpecific22.java @@ -25,13 +25,18 @@ * @test * @bug 8143852 * @summary Most specific inference constraints derived from both functional interface method parameters and tparam bounds - * @compile MostSpecific22.java */ -class MostSpecific22 { +public class MostSpecific22 { + public static void main(String[] args) { + new MostSpecific22().test(); + } + interface F1 { Object apply(T arg); } interface F2 { String apply(Number arg); } - static T m1(F1 f) { return null; } + static T m1(F1 f) { + throw new RuntimeException("Less-specific method invocation."); + } static Object m1(F2 f) { return null; } static String foo(Object in) { return "a"; } diff --git a/test/tools/javac/lambda/MostSpecific27.java b/test/tools/javac/lambda/MostSpecific27.java --- a/test/tools/javac/lambda/MostSpecific27.java +++ b/test/tools/javac/lambda/MostSpecific27.java @@ -25,13 +25,18 @@ * @test * @bug 8143852 * @summary Most specific inference constraints derived from intersection bound - * @compile MostSpecific27.java */ -class MostSpecific27 { +public class MostSpecific27 { + public static void main(String[] args) { + new MostSpecific27().test(); + } + interface F1 { & Runnable> Object apply(T arg); } interface F2 { & Runnable> String apply(Number arg); } - static T m1(F1 f) { return null; } + static T m1(F1 f) { + throw new RuntimeException("Less-specific method invocation."); + } static Object m1(F2 f) { return null; } static String foo(Object in) { return "a"; } diff --git a/test/tools/javac/lambda/MostSpecific29.java b/test/tools/javac/lambda/MostSpecific29.java --- a/test/tools/javac/lambda/MostSpecific29.java +++ b/test/tools/javac/lambda/MostSpecific29.java @@ -25,15 +25,20 @@ * @test * @bug 8144767 * @summary Correct most-specific test when wildcards appear in functional interface type - * @compile MostSpecific29.java */ -class MostSpecific29 { +public class MostSpecific29 { + + public static void main(String[] args) { + new MostSpecific29().test(); + } interface Pred { boolean test(T arg); } interface Fun { R apply(T arg); } static void m1(Pred f) {} - static void m1(Fun f) {} + static void m1(Fun f) { + throw new RuntimeException("Less-specific method invocation."); + } void test() { m1((Integer n) -> true);