< prev index next >

test/langtools/tools/javac/TryWithResources/BadTwrSyntax.java

Print this page


   1 /*
   2  * @test  /nodynamiccopyright/
   3  * @bug 6911256 6964740
   4  * @author Joseph D. Darcy
   5  * @summary Verify bad TWRs don't compile
   6  * @compile/fail/ref=BadTwrSyntax6.out -XDrawDiagnostics -source 6 BadTwrSyntax.java
   7  * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java
   8  */
   9 
  10 import java.io.IOException;
  11 public class BadTwrSyntax implements AutoCloseable {
  12     public static void main(String... args) throws Exception {
  13         // illegal double semicolon ending resources
  14         try(BadTwr twrflow = new BadTwr();;) {
  15             System.out.println(twrflow.toString());
  16         }
  17 
  18         // but one semicolon is fine
  19         try(BadTwr twrflow = new BadTwr();) {
  20             System.out.println(twrflow.toString());
  21         }
  22     }
  23 
  24     public void close() {
  25         ;
  26     }
   1 /*
   2  * @test  /nodynamiccopyright/
   3  * @bug 6911256 6964740
   4  * @author Joseph D. Darcy
   5  * @summary Verify bad TWRs don't compile

   6  * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java
   7  */
   8 
   9 import java.io.IOException;
  10 public class BadTwrSyntax implements AutoCloseable {
  11     public static void main(String... args) throws Exception {
  12         // illegal double semicolon ending resources
  13         try(BadTwr twrflow = new BadTwr();;) {
  14             System.out.println(twrflow.toString());
  15         }
  16 
  17         // but one semicolon is fine
  18         try(BadTwr twrflow = new BadTwr();) {
  19             System.out.println(twrflow.toString());
  20         }
  21     }
  22 
  23     public void close() {
  24         ;
  25     }
< prev index next >