aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 6911256 6964740 6965277 7013420 aoqi@0: * @author Maurizio Cimadamore aoqi@0: * @summary Test that resource variables are implicitly final aoqi@0: * @compile/fail/ref=ImplicitFinal.out -XDrawDiagnostics ImplicitFinal.java aoqi@0: */ aoqi@0: aoqi@0: import java.io.IOException; aoqi@0: aoqi@0: class ImplicitFinal implements AutoCloseable { aoqi@0: public static void main(String... args) { aoqi@0: try(ImplicitFinal r = new ImplicitFinal()) { aoqi@0: r = null; //disallowed aoqi@0: } catch (IOException ioe) { // Not reachable aoqi@0: throw new AssertionError("Shouldn't reach here", ioe); aoqi@0: } aoqi@0: aoqi@0: try(@SuppressWarnings("unchecked") ImplicitFinal r1 = new ImplicitFinal()) { aoqi@0: r1 = null; //disallowed aoqi@0: } catch (IOException ioe) { // Not reachable aoqi@0: throw new AssertionError("Shouldn't reach here", ioe); aoqi@0: } aoqi@0: aoqi@0: try(final ImplicitFinal r2 = new ImplicitFinal()) { aoqi@0: r2 = null; //disallowed aoqi@0: } catch (IOException ioe) { // Not reachable aoqi@0: throw new AssertionError("Shouldn't reach here", ioe); aoqi@0: } aoqi@0: aoqi@0: try(final @SuppressWarnings("unchecked") ImplicitFinal r3 = new ImplicitFinal()) { aoqi@0: r3 = null; //disallowed aoqi@0: } catch (IOException ioe) { // Not reachable aoqi@0: throw new AssertionError("Shouldn't reach here", ioe); aoqi@0: } aoqi@0: } aoqi@0: public void close() throws IOException { aoqi@0: throw new IOException(); aoqi@0: } aoqi@0: }