Cross Reference: ResourceOutsideTry.java
xref
: /
openjdk7
/
langtools
/
test
/
tools
/
javac
/
TryWithResources
/
ResourceOutsideTry.java
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
608
N/A
/*
608
N/A
* @test /nodynamiccopyright/
608
N/A
* @bug 6911256 6964740 6965277
608
N/A
* @author Maurizio Cimadamore
608
N/A
* @summary Check that resource variable is not accessible from
catch
/
finally
clause
608
N/A
* @
compile
/
fail
/
ref
=ResourceOutsideTry.out -XDrawDiagnostics
ResourceOutsideTry.java
608
N/A
*/
608
N/A
608
N/A
class
ResourceOutsideTry
{
608
N/A
void
test
() {
608
N/A
try
(
MyResource
c =
new
MyResource
()) {
608
N/A
//do something
608
N/A
}
catch
(
Exception
e) {
608
N/A
c.
test
();
608
N/A
}
finally
{
608
N/A
c.
test
();
608
N/A
}
608
N/A
}
608
N/A
static
class
MyResource
implements
AutoCloseable
{
608
N/A
public
void
close
()
throws
Exception
{}
608
N/A
void
test
() {}
608
N/A
}
608
N/A
}