Fri, 24 Apr 2020 03:58:51 +0100
Merge
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 6911256 6964740
4 * @author Joseph D. Darcy
5 * @summary Verify bad TWRs don't compile
6 * @compile/fail -source 6 TwrFlow.java
7 * @compile/fail/ref=BadTwr.out -XDrawDiagnostics BadTwr.java
8 */
10 public class BadTwr implements AutoCloseable {
11 public static void main(String... args) {
12 // illegal repeated name
13 try(BadTwr r1 = new BadTwr(); BadTwr r1 = new BadTwr()) {
14 System.out.println(r1.toString());
15 }
17 // illegal duplicate name of method argument
18 try(BadTwr args = new BadTwr()) {
19 System.out.println(args.toString());
20 final BadTwr thatsIt = new BadTwr();
21 thatsIt = null;
22 }
24 try(BadTwr name = new BadTwr()) {
25 // illegal duplicate name of enclosing try
26 try(BadTwr name = new BadTwr()) {
27 System.out.println(name.toString());
28 }
29 }
31 }
33 public void close() {
34 ;
35 }
36 }