test/tools/javac/TryWithResources/BadTwrSyntax.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/TryWithResources/BadTwrSyntax.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,27 @@
     1.4 +/*
     1.5 + * @test  /nodynamiccopyright/
     1.6 + * @bug 6911256 6964740
     1.7 + * @author Joseph D. Darcy
     1.8 + * @summary Verify bad TWRs don't compile
     1.9 + * @compile/fail -source 6 BadTwrSyntax.java
    1.10 + * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java
    1.11 + */
    1.12 +
    1.13 +import java.io.IOException;
    1.14 +public class BadTwrSyntax implements AutoCloseable {
    1.15 +    public static void main(String... args) throws Exception {
    1.16 +        // illegal double semicolon ending resources
    1.17 +        try(BadTwr twrflow = new BadTwr();;) {
    1.18 +            System.out.println(twrflow.toString());
    1.19 +        }
    1.20 +
    1.21 +        // but one semicolon is fine
    1.22 +        try(BadTwr twrflow = new BadTwr();) {
    1.23 +            System.out.println(twrflow.toString());
    1.24 +        }
    1.25 +    }
    1.26 +
    1.27 +    public void close() {
    1.28 +        ;
    1.29 +    }
    1.30 +}

mercurial