Fri, 24 Apr 2020 03:58:51 +0100
Merge
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 */
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 */
15 public class ResourceNameConflict implements AutoCloseable {
17 static final String str = "asdf";
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 }
25 void test2(String... strArray) {
26 for (String str : strArray) {
27 try (ResourceNameConflict str = new ResourceNameConflict()) {
28 }
29 }
30 }
32 @Override
33 public void close() {
34 }
35 }