Fri, 12 Nov 2010 12:34:18 +0000
6970016: Clean up ARM/try-with-resources implementation
Summary: changed Xlint option name from -Xlint:arm to -Xlint:try
Reviewed-by: jjg
darcy@609 | 1 | /* |
darcy@609 | 2 | * @test /nodynamiccopyright/ |
darcy@609 | 3 | * @bug 6911256 6964740 6965277 |
darcy@609 | 4 | * @author Maurizio Cimadamore |
darcy@609 | 5 | * @summary Check that resources of an intersection type forces union of exception types |
darcy@609 | 6 | * to be caught outside twr block |
darcy@609 | 7 | * @compile/fail/ref=TwrIntersection02.out -XDrawDiagnostics TwrIntersection02.java |
darcy@609 | 8 | */ |
darcy@609 | 9 | |
darcy@609 | 10 | class TwrIntersection02 { |
darcy@609 | 11 | |
darcy@609 | 12 | static class Exception1 extends Exception {} |
darcy@609 | 13 | static class Exception2 extends Exception {} |
darcy@609 | 14 | |
darcy@609 | 15 | |
darcy@609 | 16 | interface MyResource1 extends AutoCloseable { |
darcy@609 | 17 | void close() throws Exception1; |
darcy@609 | 18 | } |
darcy@609 | 19 | |
darcy@609 | 20 | interface MyResource2 extends AutoCloseable { |
darcy@609 | 21 | void close() throws Exception2; |
darcy@609 | 22 | } |
darcy@609 | 23 | |
darcy@609 | 24 | public void test1() throws Exception1 { |
darcy@609 | 25 | try(getX()) { |
darcy@609 | 26 | //do something |
darcy@609 | 27 | } |
darcy@609 | 28 | } |
darcy@609 | 29 | |
darcy@609 | 30 | public void test2() throws Exception2 { |
darcy@609 | 31 | try(getX()) { |
darcy@609 | 32 | //do something |
darcy@609 | 33 | } |
darcy@609 | 34 | } |
darcy@609 | 35 | |
darcy@609 | 36 | <X extends MyResource1 & MyResource2> X getX() { return null; } |
darcy@609 | 37 | } |