test/tools/javac/TryWithResources/TwrIntersection02.java

Fri, 16 Jul 2010 19:35:24 -0700

author
darcy
date
Fri, 16 Jul 2010 19:35:24 -0700
changeset 609
13354e1abba7
permissions
-rw-r--r--

6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
6964740: Project Coin: More tests for ARM compiler changes
6965277: Project Coin: Correctness issues in ARM implementation
6967065: add -Xlint warning category for Automatic Resource Management (ARM)
Reviewed-by: jjb, darcy, mcimadamore, jjg, briangoetz
Contributed-by: tball@google.com

     1 /*
     2  * @test  /nodynamiccopyright/
     3  * @bug 6911256 6964740 6965277
     4  * @author Maurizio Cimadamore
     5  * @summary Check that resources of an intersection type forces union of exception types
     6  *          to be caught outside twr block
     7  * @compile/fail/ref=TwrIntersection02.out -XDrawDiagnostics TwrIntersection02.java
     8  */
    10 class TwrIntersection02 {
    12     static class Exception1 extends Exception {}
    13     static class Exception2 extends Exception {}
    16     interface MyResource1 extends AutoCloseable {
    17        void close() throws Exception1;
    18     }
    20     interface MyResource2 extends AutoCloseable {
    21        void close() throws Exception2;
    22     }
    24     public void test1() throws Exception1 {
    25         try(getX()) {
    26             //do something
    27         }
    28     }
    30     public void test2() throws Exception2 {
    31         try(getX()) {
    32             //do something
    33         }
    34     }
    36     <X extends MyResource1 & MyResource2> X getX() { return null; }
    37 }

mercurial