Fri, 16 Jul 2010 19:35:24 -0700
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
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 Test that resource variables are implicitly final |
darcy@609 | 6 | * @compile/fail/ref=ImplicitFinal.out -XDrawDiagnostics ImplicitFinal.java |
darcy@609 | 7 | */ |
darcy@609 | 8 | |
darcy@609 | 9 | import java.io.IOException; |
darcy@609 | 10 | |
darcy@609 | 11 | class ImplicitFinal implements AutoCloseable { |
darcy@609 | 12 | public static void main(String... args) { |
darcy@609 | 13 | try(ImplicitFinal r = new ImplicitFinal()) { |
darcy@609 | 14 | r = null; //disallowed |
darcy@609 | 15 | } catch (IOException ioe) { // Not reachable |
darcy@609 | 16 | throw new AssertionError("Shouldn't reach here", ioe); |
darcy@609 | 17 | } |
darcy@609 | 18 | } |
darcy@609 | 19 | |
darcy@609 | 20 | |
darcy@609 | 21 | // A close method, but the class is <em>not</em> Closeable or |
darcy@609 | 22 | // AutoCloseable. |
darcy@609 | 23 | |
darcy@609 | 24 | public void close() throws IOException { |
darcy@609 | 25 | throw new IOException(); |
darcy@609 | 26 | } |
darcy@609 | 27 | } |