Tom Ball 985efdc475 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
6964740: Project Coin: More tests for ARM compiler changes
6965277: Project Coin: Correctness issues in ARM implementation
6967065: add -Xlint warning category for Automatic Resource Management (ARM)

Reviewed-by: jjb, darcy, mcimadamore, jjg, briangoetz
2010-07-16 19:35:24 -07:00

56 lines
1.3 KiB
Java

/*
* @test /nodynamiccopyright/
* @bug 6911256 6964740 6965277 6967065
* @author Joseph D. Darcy
* @summary Check that -Xlint:arm warnings are generated as expected
* @compile/ref=ArmLint.out -Xlint:arm,deprecation -XDrawDiagnostics ArmLint.java
*/
class ArmLint implements AutoCloseable {
private static void test1() {
try(ArmLint r1 = new ArmLint();
ArmLint r2 = new ArmLint();
ArmLint r3 = new ArmLint()) {
r1.close(); // The resource's close
r2.close(42); // *Not* the resource's close
// r3 not referenced
}
}
@SuppressWarnings("arm")
private static void test2() {
try(@SuppressWarnings("deprecation") AutoCloseable r4 =
new DeprecatedAutoCloseable()) {
// r4 not referenced
} catch(Exception e) {
;
}
}
/**
* The AutoCloseable method of a resource.
*/
@Override
public void close () {
return;
}
/**
* <em>Not</em> the AutoCloseable method of a resource.
*/
public void close (int arg) {
return;
}
}
@Deprecated
class DeprecatedAutoCloseable implements AutoCloseable {
public DeprecatedAutoCloseable(){super();}
@Override
public void close () {
return;
}
}