changeset 43033:c37b643739a7

8148100: Convert lambda most specific positive tests to check runtime behavior Reviewed-by: mcimadamore Contributed-by: bsrbnd@gmail.com
author vromero
date Thu, 05 Jan 2017 11:16:39 -0800
parents 8a98364c8c69
children 09436b637cb5
files langtools/test/tools/javac/lambda/MostSpecific10.java langtools/test/tools/javac/lambda/MostSpecific11.java langtools/test/tools/javac/lambda/MostSpecific15.java langtools/test/tools/javac/lambda/MostSpecific17.java langtools/test/tools/javac/lambda/MostSpecific18.java langtools/test/tools/javac/lambda/MostSpecific20.java langtools/test/tools/javac/lambda/MostSpecific22.java langtools/test/tools/javac/lambda/MostSpecific27.java langtools/test/tools/javac/lambda/MostSpecific29.java
diffstat 9 files changed, 89 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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() {
--- 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 { <X> Object apply(X arg); }
     interface F2 { <Y> 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
+}
--- 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<T> {}
     interface B<T> extends A<T> {}
@@ -35,7 +38,9 @@
     interface F1 { <X> A<? super X> apply(Object arg); }
     interface F2 { <Y> B<? super Y> 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<Object> foo(Object in) { return null; }
@@ -43,5 +48,4 @@
     void test() {
         m1(MostSpecific17::foo);
     }
-
-}
\ No newline at end of file
+}
--- 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 { <X extends Number> Object apply(X arg); }
     interface F2 { <Y extends Number> 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
+}
--- 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 { <X extends Iterable<X>> Object apply(X arg); }
     interface F2 { <Y extends Iterable<Y>> 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
+}
--- 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<T> { <X extends T> Object apply(T arg); }
     interface F2 { <Y extends Number> String apply(Number arg); }
 
-    static <T> T m1(F1<T> f) { return null; }
+    static <T> T m1(F1<T> 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
+}
--- 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<T> { <X extends Iterable<T> & Runnable> Object apply(T arg); }
     interface F2 { <Y extends Iterable<Number> & Runnable> String apply(Number arg); }
 
-    static <T> T m1(F1<T> f) { return null; }
+    static <T> T m1(F1<T> 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
+}
--- 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<T> { boolean test(T arg); }
     interface Fun<T,R> { R apply(T arg); }
 
     static void m1(Pred<? super Integer> f) {}
-    static void m1(Fun<Integer, Boolean> f) {}
+    static void m1(Fun<Integer, Boolean> f) {
+        throw new AssertionError("Less-specific method invocation.");
+    }
 
     void test() {
         m1((Integer n) -> true);