Fri, 30 May 2014 12:54:16 +0200
8031967: For some sources compiler compiles for ever
Summary: Avoid creating DeferredTypes for method calls with method calls as receivers if the site can be determined reliably
Reviewed-by: mcimadamore, vromero
Contributed-by: maurizio.cimadamore@oracle.com, jan.lahoda@oracle.com
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8003280
4 * @summary Add lambda tests
5 * check that inner scopes are left after a lambda check exception has been thrown
6 * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
7 */
8 class LambdaExpr19 {
10 interface SAM {
11 String m();
12 }
14 void m(SAM s) { }
16 void testTry() {
17 m(() -> {
18 try { return 1; }
19 catch (Exception e) { }
20 });
21 }
23 void testTryWithResources() {
24 m(() -> {
25 try (AutoCloseable c = null) { return 1; }
26 catch (Exception e) { }
27 });
28 }
30 void testSwitch() {
31 m(() -> {
32 switch (1) {
33 default: return 1;
34 }
35 });
36 }
38 void testFor() {
39 m(() -> {
40 for (;;) {
41 return 1;
42 }
43 });
44 }
46 void testForeach() {
47 m(() -> {
48 for (Object o : new Object[] { null , null }) {
49 return 1;
50 }
51 });
52 }
53 }