author | mchung |
Wed, 27 May 2015 13:25:18 -0700 | |
changeset 30846 | 2b3f379840f0 |
parent 27844 | 8b5d79870a2f |
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 Resources cannot be declared outside t-w-r block |
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
6 |
* @compile/fail/ref=ResDeclOutsideTry.out -XDrawDiagnostics ResDeclOutsideTry.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 |
public class ResDeclOutsideTry implements AutoCloseable { |
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
10 |
ResDeclOutsideTry tr1; |
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
11 |
ResDeclOutsideTry tr2 = new ResDeclOutsideTry(); |
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
12 |
|
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
13 |
String test1() { |
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
14 |
try (tr1 = new ResDeclOutsideTry(); tr2;) { |
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
15 |
} |
27844
8b5d79870a2f
7196163: Project Coin: Allow effectively final variables to be used as resources in try-with-resources
jlahoda
parents:
21714
diff
changeset
|
16 |
return null; |
8b5d79870a2f
7196163: Project Coin: Allow effectively final variables to be used as resources in try-with-resources
jlahoda
parents:
21714
diff
changeset
|
17 |
} |
8b5d79870a2f
7196163: Project Coin: Allow effectively final variables to be used as resources in try-with-resources
jlahoda
parents:
21714
diff
changeset
|
18 |
|
8b5d79870a2f
7196163: Project Coin: Allow effectively final variables to be used as resources in try-with-resources
jlahoda
parents:
21714
diff
changeset
|
19 |
@Override |
8b5d79870a2f
7196163: Project Coin: Allow effectively final variables to be used as resources in try-with-resources
jlahoda
parents:
21714
diff
changeset
|
20 |
public void close() throws Exception { |
21714
f5b7edec4304
8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff
changeset
|
21 |
} |
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 |