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