1 /*
 2  * @test    /nodynamiccopyright/
 3  * @bug     8025113
 4  * @author  sogoel
 5  * @summary Redeclaration of resource variables
 6  * @compile/fail/ref=ResourceRedecl.out -XDrawDiagnostics ResourceRedecl.java
 7  */
 8 
 9 import java.io.*;
10 
11 public class ResourceRedecl {
12 
13     public void test() {
14         // compiler error if name of an exception param is redeclared within the Block of the catch clause as a local var;
15         // or as an exception param of a catch clause in a try statement;
16         // or as a resource in a try-with-resources statement
17         try {
18         } catch (Exception exParam1) {
19             Object exParam1 = new Object();
20             try (java.io.FileInputStream exParam1 = new java.io.FileInputStream("foo.txt")) {
21                 Object exParam1 = new Object();
22             } catch (IOException exParam1) {
23             }
24         }
25 
26         // compiler error if resource is redeclared within the try Block as a local var
27         // or as an exception param of a catch clause in a try statement
28         try (java.io.FileInputStream exParam2 = new java.io.FileInputStream("bar.txt")) {
29             Object exParam2 = new Object();
30             try (BufferedReader br = new BufferedReader(new FileReader("zee.txt"))) {
31             } catch (IOException exParam2) {
32             }
33         } catch (Exception ex) {
34         }
35     }
36 }
37