Thu, 31 Aug 2017 15:17:03 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 6911256 6964740 7013420 |
aoqi@0 | 4 | * @author Joseph D. Darcy |
aoqi@0 | 5 | * @summary Test exception analysis of try-with-resources blocks |
aoqi@0 | 6 | * @compile/fail/ref=TwrFlow.out -XDrawDiagnostics TwrFlow.java |
aoqi@0 | 7 | */ |
aoqi@0 | 8 | |
aoqi@0 | 9 | import java.io.IOException; |
aoqi@0 | 10 | public class TwrFlow implements AutoCloseable { |
aoqi@0 | 11 | public static void main(String... args) { |
aoqi@0 | 12 | try(TwrFlow twrFlow = new TwrFlow()) { |
aoqi@0 | 13 | System.out.println(twrFlow.toString()); |
aoqi@0 | 14 | } catch (IOException ioe) { // Not reachable |
aoqi@0 | 15 | throw new AssertionError("Shouldn't reach here", ioe); |
aoqi@0 | 16 | } |
aoqi@0 | 17 | // CustomCloseException should be caught or added to throws clause |
aoqi@0 | 18 | } |
aoqi@0 | 19 | |
aoqi@0 | 20 | /* |
aoqi@0 | 21 | * A close method, but the class is <em>not</em> Closeable or |
aoqi@0 | 22 | * AutoCloseable. |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | public void close() throws CustomCloseException { |
aoqi@0 | 25 | throw new CustomCloseException(); |
aoqi@0 | 26 | } |
aoqi@0 | 27 | } |
aoqi@0 | 28 | |
aoqi@0 | 29 | class CustomCloseException extends Exception {} |