Tue, 15 Feb 2011 11:51:04 +0000
7017104: improve error reporting for uncaught/undeclared exceptions from try-with-resources
Summary: twr should generate better error message when uncaught exceptions are thrown by implicit call of close() method
Reviewed-by: jjg
darcy@609 | 1 | /* |
darcy@609 | 2 | * @test /nodynamiccopyright/ |
darcy@609 | 3 | * @bug 6911256 6964740 |
darcy@609 | 4 | * @author Joseph D. Darcy |
darcy@609 | 5 | * @summary Verify bad TWRs don't compile |
darcy@609 | 6 | * @compile/fail -source 6 BadTwrSyntax.java |
darcy@850 | 7 | * @compile/fail/ref=BadTwrSyntax.out -XDrawDiagnostics BadTwrSyntax.java |
darcy@609 | 8 | */ |
darcy@609 | 9 | |
darcy@609 | 10 | import java.io.IOException; |
darcy@609 | 11 | public class BadTwrSyntax implements AutoCloseable { |
darcy@609 | 12 | public static void main(String... args) throws Exception { |
darcy@850 | 13 | // illegal double semicolon ending resources |
darcy@850 | 14 | try(BadTwr twrflow = new BadTwr();;) { |
darcy@850 | 15 | System.out.println(twrflow.toString()); |
darcy@850 | 16 | } |
darcy@850 | 17 | |
darcy@850 | 18 | // but one semicolon is fine |
darcy@609 | 19 | try(BadTwr twrflow = new BadTwr();) { |
darcy@609 | 20 | System.out.println(twrflow.toString()); |
darcy@609 | 21 | } |
darcy@609 | 22 | } |
darcy@609 | 23 | |
darcy@609 | 24 | public void close() { |
darcy@609 | 25 | ; |
darcy@609 | 26 | } |
darcy@609 | 27 | } |