langtools/test/tools/javac/TryWithResources/ArmLint.java
changeset 7565 0fa5baf68639
parent 7308 95b4878b4890
parent 7217 8c840d3ab24f
child 7566 39a122ae85a8
equal deleted inserted replaced
7308:95b4878b4890 7565:0fa5baf68639
     1 /*
       
     2  * @test  /nodynamiccopyright/
       
     3  * @bug 6911256 6964740 6965277 6967065
       
     4  * @author Joseph D. Darcy
       
     5  * @summary Check that -Xlint:arm warnings are generated as expected
       
     6  * @compile/ref=ArmLint.out -Xlint:arm,deprecation -XDrawDiagnostics ArmLint.java
       
     7  */
       
     8 
       
     9 class ArmLint implements AutoCloseable {
       
    10     private static void test1() {
       
    11         try(ArmLint r1 = new ArmLint();
       
    12             ArmLint r2 = new ArmLint();
       
    13             ArmLint r3 = new ArmLint()) {
       
    14             r1.close();   // The resource's close
       
    15             r2.close(42); // *Not* the resource's close
       
    16             // r3 not referenced
       
    17         }
       
    18 
       
    19     }
       
    20 
       
    21     @SuppressWarnings("arm")
       
    22     private static void test2() {
       
    23         try(@SuppressWarnings("deprecation") AutoCloseable r4 =
       
    24             new DeprecatedAutoCloseable()) {
       
    25             // r4 not referenced
       
    26         } catch(Exception e) {
       
    27             ;
       
    28         }
       
    29     }
       
    30 
       
    31     /**
       
    32      * The AutoCloseable method of a resource.
       
    33      */
       
    34     @Override
       
    35     public void close () {
       
    36         return;
       
    37     }
       
    38 
       
    39     /**
       
    40      * <em>Not</em> the AutoCloseable method of a resource.
       
    41      */
       
    42     public void close (int arg) {
       
    43         return;
       
    44     }
       
    45 }
       
    46 
       
    47 @Deprecated
       
    48 class DeprecatedAutoCloseable implements AutoCloseable {
       
    49     public DeprecatedAutoCloseable(){super();}
       
    50 
       
    51     @Override
       
    52     public void close () {
       
    53         return;
       
    54     }
       
    55 }