test/tools/javac/TryWithResources/TwrFlow.java

Thu, 07 Jun 2012 20:30:57 -0700

author
erikj
date
Thu, 07 Jun 2012 20:30:57 -0700
changeset 1273
ac29cc95b5c5
parent 840
7f8794f9cc14
child 2525
2eb010b6cb22
permissions
-rw-r--r--

7170079: Adjustments to build-infra makefiles
Reviewed-by: ohair, ohrstrom, ihse, jonas
Contributed-by: jonas <jonas.oreland@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>

     1 /*
     2  * @test  /nodynamiccopyright/
     3  * @bug 6911256 6964740 7013420
     4  * @author Joseph D. Darcy
     5  * @summary Test exception analysis of try-with-resources 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 twrFlow = new TwrFlow()) {
    13             System.out.println(twrFlow.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
    18     }
    20     /*
    21      * A close method, but the class is <em>not</em> Closeable or
    22      * AutoCloseable.
    23      */
    24     public void close() throws CustomCloseException {
    25         throw new CustomCloseException();
    26     }
    27 }
    29 class CustomCloseException extends Exception {}

mercurial