# HG changeset patch # User vromero # Date 1483643799 28800 # Node ID c37b643739a7923a9443346c51ce6b577c17bb0a # Parent 8a98364c8c695f153ee8dc33496188586efe24b6 8148100: Convert lambda most specific positive tests to check runtime behavior Reviewed-by: mcimadamore Contributed-by: bsrbnd@gmail.com diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific10.java --- a/langtools/test/tools/javac/lambda/MostSpecific10.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific10.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,13 @@ * @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 +42,9 @@ } void m(GetInt getter) {} - void m(GetInteger getter) {} + void m(GetInteger getter) { + throw new AssertionError("Less-specific method invocation: " + getter.getClass()); + } void test(boolean cond) { m(() -> 23); diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific11.java --- a/langtools/test/tools/javac/lambda/MostSpecific11.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific11.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific15.java --- a/langtools/test/tools/javac/lambda/MostSpecific15.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific15.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 AssertionError("Less-specific method invocation."); + } static void m1(F2 f) {} static String foo(Object in) { return "a"; } @@ -39,5 +44,4 @@ void test() { m1(MostSpecific15::foo); } - -} \ No newline at end of file +} diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific17.java --- a/langtools/test/tools/javac/lambda/MostSpecific17.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific17.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 AssertionError("Less-specific method invocation."); + } static void m1(F2 f) {} static B foo(Object in) { return null; } @@ -43,5 +48,4 @@ void test() { m1(MostSpecific17::foo); } - -} \ No newline at end of file +} diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific18.java --- a/langtools/test/tools/javac/lambda/MostSpecific18.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific18.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 AssertionError("Less-specific method invocation."); + } static void m1(F2 f) {} static String foo(Object in) { return "a"; } @@ -39,5 +44,4 @@ void test() { m1(MostSpecific18::foo); } - -} \ No newline at end of file +} diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific20.java --- a/langtools/test/tools/javac/lambda/MostSpecific20.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific20.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 AssertionError("Less-specific method invocation."); + } static void m1(F2 f) {} static String foo(Object in) { return "a"; } @@ -39,5 +44,4 @@ void test() { m1(MostSpecific20::foo); } - -} \ No newline at end of file +} diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific22.java --- a/langtools/test/tools/javac/lambda/MostSpecific22.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific22.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,19 @@ * @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 AssertionError("Less-specific method invocation."); + } static Object m1(F2 f) { return null; } static String foo(Object in) { return "a"; } @@ -40,4 +46,4 @@ m1(MostSpecific22::foo); } -} \ No newline at end of file +} diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific27.java --- a/langtools/test/tools/javac/lambda/MostSpecific27.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific27.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 AssertionError("Less-specific method invocation."); + } static Object m1(F2 f) { return null; } static String foo(Object in) { return "a"; } @@ -40,4 +45,4 @@ m1(MostSpecific27::foo); } -} \ No newline at end of file +} diff -r 8a98364c8c69 -r c37b643739a7 langtools/test/tools/javac/lambda/MostSpecific29.java --- a/langtools/test/tools/javac/lambda/MostSpecific29.java Thu Jan 05 19:10:24 2017 +0000 +++ b/langtools/test/tools/javac/lambda/MostSpecific29.java Thu Jan 05 11:16:39 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 AssertionError("Less-specific method invocation."); + } void test() { m1((Integer n) -> true);