< prev index next >

test/langtools/tools/javac/TryWithResources/TwrOnNonResource.java

Print this page


   1 /*
   2  * @test  /nodynamiccopyright/
   3  * @bug 6911256 6964740 7013420
   4  * @author Joseph D. Darcy
   5  * @summary Verify invalid TWR block is not accepted.
   6  * @compile/fail/ref=TwrOnNonResource6.out -XDrawDiagnostics -source 6 TwrOnNonResource.java
   7  * @compile/fail/ref=TwrOnNonResource.out -XDrawDiagnostics TwrOnNonResource.java
   8  */
   9 
  10 class TwrOnNonResource {
  11     public static void main(String... args) {
  12         try(TwrOnNonResource aonr = new TwrOnNonResource()) {
  13             System.out.println(aonr.toString());
  14         }
  15         try(TwrOnNonResource aonr = new TwrOnNonResource()) {
  16             System.out.println(aonr.toString());
  17         } finally {;}
  18         try(TwrOnNonResource aonr = new TwrOnNonResource()) {
  19             System.out.println(aonr.toString());
  20         } catch (Exception e) {;}
  21     }
  22 
  23     /*
  24      * A close method, but the class is <em>not</em> Closeable or
  25      * AutoCloseable.
  26      */
   1 /*
   2  * @test  /nodynamiccopyright/
   3  * @bug 6911256 6964740 7013420
   4  * @author Joseph D. Darcy
   5  * @summary Verify invalid TWR block is not accepted.

   6  * @compile/fail/ref=TwrOnNonResource.out -XDrawDiagnostics TwrOnNonResource.java
   7  */
   8 
   9 class TwrOnNonResource {
  10     public static void main(String... args) {
  11         try(TwrOnNonResource aonr = new TwrOnNonResource()) {
  12             System.out.println(aonr.toString());
  13         }
  14         try(TwrOnNonResource aonr = new TwrOnNonResource()) {
  15             System.out.println(aonr.toString());
  16         } finally {;}
  17         try(TwrOnNonResource aonr = new TwrOnNonResource()) {
  18             System.out.println(aonr.toString());
  19         } catch (Exception e) {;}
  20     }
  21 
  22     /*
  23      * A close method, but the class is <em>not</em> Closeable or
  24      * AutoCloseable.
  25      */
< prev index next >