|
1 /* |
|
2 * @test /nodynamiccopyright/ |
|
3 * @bug 8025113 |
|
4 * @author sogoel |
|
5 * @summary Resource var cannot have same name as local variable |
|
6 * @compile/fail/ref=ResourceNameConflict.out -XDrawDiagnostics ResourceNameConflict.java |
|
7 */ |
|
8 |
|
9 /** |
|
10 * Test methods and their description |
|
11 * test1() - negative test - local variable used as test resource |
|
12 * test2() - negative test - test resource already defined in an enclosing for statement |
|
13 */ |
|
14 |
|
15 public class ResourceNameConflict implements AutoCloseable { |
|
16 |
|
17 static final String str = "asdf"; |
|
18 |
|
19 void test1() { |
|
20 String tr = "A resource spec var cannot have same name as local var."; |
|
21 try (ResourceNameConflict tr = new ResourceNameConflict()) { |
|
22 } |
|
23 } |
|
24 |
|
25 void test2(String... strArray) { |
|
26 for (String str : strArray) { |
|
27 try (ResourceNameConflict str = new ResourceNameConflict()) { |
|
28 } |
|
29 } |
|
30 } |
|
31 |
|
32 @Override |
|
33 public void close() { |
|
34 } |
|
35 } |
|
36 |