test/tools/javac/TryWithResources/TwrFlow.java

Wed, 01 Dec 2010 11:02:38 -0800

author
bpatel
date
Wed, 01 Dec 2010 11:02:38 -0800
changeset 766
90af8d87741f
parent 609
13354e1abba7
child 840
7f8794f9cc14
permissions
-rw-r--r--

6851834: Javadoc doclet needs a structured approach to generate the output HTML.
Reviewed-by: jjg

     1 /*
     2  * @test  /nodynamiccopyright/
     3  * @bug 6911256 6964740
     4  * @author Joseph D. Darcy
     5  * @summary Test exception analysis of ARM blocks
     6  * @compile/fail/ref=TwrFlow.out -XDrawDiagnostics TwrFlow.java
     7  */
     9 import java.io.IOException;
    10 public class TwrFlow implements AutoCloseable {
    11     public static void main(String... args) {
    12         try(TwrFlow armflow = new TwrFlow()) {
    13             System.out.println(armflow.toString());
    14         } catch (IOException ioe) { // Not reachable
    15             throw new AssertionError("Shouldn't reach here", ioe);
    16         }
    17         // CustomCloseException should be caught or added to throws clause
    19         // Also check behavior on a resource expression rather than a
    20         // declaration.
    21         TwrFlow armflowexpr = new TwrFlow();
    22         try(armflowexpr) {
    23             System.out.println(armflowexpr.toString());
    24         } catch (IOException ioe) { // Not reachable
    25             throw new AssertionError("Shouldn't reach here", ioe);
    26         }
    27         // CustomCloseException should be caught or added to throws clause
    28     }
    30     /*
    31      * A close method, but the class is <em>not</em> Closeable or
    32      * AutoCloseable.
    33      */
    34     public void close() throws CustomCloseException {
    35         throw new CustomCloseException();
    36     }
    37 }
    39 class CustomCloseException extends Exception {}

mercurial