jdk-24/langtools/test/tools/javac/lambda/methodReference/MethodRefToInnerWithoutOuter.java
Srikanth Adayapalam 4815781a4a 8081271: NPE while compiling a program with erroneous use of constructor reference expressions
Missing enclosing instance error should not be swallowed when attributing constructor reference expressions.

Reviewed-by: mcimadamore, vromero
2015-05-29 09:15:42 +05:30

25 lines
681 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8081271
* @summary NPE while compiling a program with erroneous use of constructor reference expressions.
* @compile/fail/ref=MethodRefToInnerWithoutOuter.out -XDrawDiagnostics MethodRefToInnerWithoutOuter.java
*/
import java.util.List;
import java.util.ArrayList;
class MethodRefToInnerBase {
class TestString {
String str;
TestString(String strin) {
str = strin;
}
}
}
public class MethodRefToInnerWithoutOuter extends MethodRefToInnerBase {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.stream().forEach(TestString::new);
}
}