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