2010-07-17 02:35:24 +00:00
|
|
|
/*
|
|
|
|
* @test /nodynamiccopyright/
|
2011-01-26 01:02:56 +00:00
|
|
|
* @bug 6911256 6964740 6965277 7013420
|
2010-07-17 02:35:24 +00:00
|
|
|
* @author Maurizio Cimadamore
|
|
|
|
* @summary Test that resource variables are implicitly final
|
|
|
|
* @compile/fail/ref=ImplicitFinal.out -XDrawDiagnostics ImplicitFinal.java
|
|
|
|
*/
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
class ImplicitFinal implements AutoCloseable {
|
2023-01-17 04:43:40 +00:00
|
|
|
public static void meth() {
|
2010-07-17 02:35:24 +00:00
|
|
|
try(ImplicitFinal r = new ImplicitFinal()) {
|
|
|
|
r = null; //disallowed
|
|
|
|
} catch (IOException ioe) { // Not reachable
|
|
|
|
throw new AssertionError("Shouldn't reach here", ioe);
|
|
|
|
}
|
|
|
|
|
2011-01-26 01:02:56 +00:00
|
|
|
try(@SuppressWarnings("unchecked") ImplicitFinal r1 = new ImplicitFinal()) {
|
|
|
|
r1 = null; //disallowed
|
|
|
|
} catch (IOException ioe) { // Not reachable
|
|
|
|
throw new AssertionError("Shouldn't reach here", ioe);
|
|
|
|
}
|
2010-07-17 02:35:24 +00:00
|
|
|
|
2011-01-26 01:02:56 +00:00
|
|
|
try(final ImplicitFinal r2 = new ImplicitFinal()) {
|
|
|
|
r2 = null; //disallowed
|
|
|
|
} catch (IOException ioe) { // Not reachable
|
|
|
|
throw new AssertionError("Shouldn't reach here", ioe);
|
|
|
|
}
|
2010-07-17 02:35:24 +00:00
|
|
|
|
2011-01-26 01:02:56 +00:00
|
|
|
try(final @SuppressWarnings("unchecked") ImplicitFinal r3 = new ImplicitFinal()) {
|
|
|
|
r3 = null; //disallowed
|
|
|
|
} catch (IOException ioe) { // Not reachable
|
|
|
|
throw new AssertionError("Shouldn't reach here", ioe);
|
|
|
|
}
|
|
|
|
}
|
2010-07-17 02:35:24 +00:00
|
|
|
public void close() throws IOException {
|
|
|
|
throw new IOException();
|
|
|
|
}
|
|
|
|
}
|