test/tools/javac/lambda/LambdaExpr19.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/LambdaExpr19.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,53 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  check that inner scopes are left after a lambda check exception has been thrown
     1.9 + * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
    1.10 + */
    1.11 +class LambdaExpr19 {
    1.12 +
    1.13 +    interface SAM {
    1.14 +        String m();
    1.15 +    }
    1.16 +
    1.17 +    void m(SAM s) { }
    1.18 +
    1.19 +    void testTry() {
    1.20 +        m(() -> {
    1.21 +                try { return 1; }
    1.22 +                catch (Exception e) { }
    1.23 +            });
    1.24 +    }
    1.25 +
    1.26 +    void testTryWithResources() {
    1.27 +        m(() -> {
    1.28 +                try (AutoCloseable c = null) { return 1; }
    1.29 +                catch (Exception e) { }
    1.30 +            });
    1.31 +    }
    1.32 +
    1.33 +    void testSwitch() {
    1.34 +        m(() -> {
    1.35 +                switch (1) {
    1.36 +                    default: return 1;
    1.37 +                }
    1.38 +            });
    1.39 +    }
    1.40 +
    1.41 +    void testFor() {
    1.42 +        m(() -> {
    1.43 +                for (;;) {
    1.44 +                    return 1;
    1.45 +                }
    1.46 +            });
    1.47 +    }
    1.48 +
    1.49 +    void testForeach() {
    1.50 +        m(() -> {
    1.51 +                for (Object o : new Object[] { null , null }) {
    1.52 +                    return 1;
    1.53 +                }
    1.54 +            });
    1.55 +    }
    1.56 +}

mercurial