test/tools/javac/lambda/TargetType52.java

Tue, 14 May 2013 11:11:09 -0700

author
rfield
date
Tue, 14 May 2013 11:11:09 -0700
changeset 1752
c09b7234cded
parent 1562
2154ed9ff6c8
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8012556: Implement lambda methods on interfaces as static
8006140: Javac NPE compiling Lambda expression on initialization expression of static field in interface
Summary: Lambdas occurring in static contexts or those not needing instance information should be generated into static methods. This has long been the case for classes. However, as a work-around to the lack of support for statics on interfaces, interface lambda methods have been generated into default methods. For lambdas in interface static contexts (fields and static methods) this causes an NPE in javac because there is no 'this'. MethodHandles now support static methods on interfaces. This changeset allows lambda methods to be generated as static interface methods. An existing bug in Hotspot (8013875) is exposed in a test when the "-esa" flag is used. This test and another test that already exposed this bug have been marked with @ignore.
Reviewed-by: mcimadamore

mcimadamore@1510 1 /*
mcimadamore@1510 2 * @test /nodynamiccopyright/
mcimadamore@1562 3 * @bug 8005244
mcimadamore@1562 4 * @summary Implement overload resolution as per latest spec EDR
mcimadamore@1562 5 * uncatched sam conversion failure exception lead to javac crash
mcimadamore@1510 6 * @compile/fail/ref=TargetType52.out -XDrawDiagnostics TargetType52.java
mcimadamore@1510 7 */
mcimadamore@1510 8 class TargetType52 {
mcimadamore@1510 9
mcimadamore@1510 10 interface FI<T extends CharSequence, V extends java.util.AbstractList<T>> {
mcimadamore@1510 11 T m(V p);
mcimadamore@1510 12 }
mcimadamore@1510 13
mcimadamore@1510 14 void m(FI<? extends CharSequence, ? extends java.util.ArrayList<? extends CharSequence>> fip) { }
mcimadamore@1510 15
mcimadamore@1510 16 void test() {
mcimadamore@1510 17 m(p -> p.get(0));
mcimadamore@1510 18 }
mcimadamore@1510 19 }

mercurial