author | sadayapalam |
Wed, 22 Nov 2017 18:07:53 +0530 | |
changeset 47880 | bbd692ad4fa3 |
permissions | -rw-r--r-- |
47880
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
1 |
/* |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
4 |
* |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
8 |
* |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
13 |
* accompanied this code). |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
14 |
* |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
18 |
* |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
21 |
* questions. |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
22 |
*/ |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
23 |
|
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
24 |
/* |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
25 |
* @test |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
26 |
* @bug 8191655 |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
27 |
* @summary LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
28 |
* @run main MethodReferenceUnionTypeTest |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
29 |
*/ |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
30 |
|
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
31 |
import java.util.function.Consumer; |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
32 |
public class MethodReferenceUnionTypeTest { |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
33 |
static String blah = "NONE"; |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
34 |
<T> void forAll(Consumer<T> consumer, T value) { consumer.accept(value); } |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
35 |
|
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
36 |
public void secondTest() { |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
37 |
try { |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
38 |
throwing(); |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
39 |
} catch (A | B ex) { |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
40 |
forAll(Picture::draw, ex); |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
41 |
} |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
42 |
} |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
43 |
|
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
44 |
void throwing() throws A, B { throw new A();} |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
45 |
|
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
46 |
interface Shape { void draw(); } |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
47 |
interface Marker { } |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
48 |
interface Picture { void draw(); } |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
49 |
|
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
50 |
class A extends Exception implements Marker, Picture { public void draw() { blah = "A"; }} |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
51 |
class B extends Exception implements Marker, Picture, Shape { public void draw() {}} |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
52 |
|
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
53 |
public static void main(String[] args) { |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
54 |
new MethodReferenceUnionTypeTest().secondTest(); |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
55 |
if (!blah.equals("A")) |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
56 |
throw new AssertionError("Incorrect output"); |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
57 |
} |
bbd692ad4fa3
8191655: LambdaConversionException: Invalid receiver type interface; not a subtype of implementation type interface
sadayapalam
parents:
diff
changeset
|
58 |
} |