test/tools/javac/TryWithResources/TwrOnNonResource.java

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

     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 -source 6 TwrOnNonResource.java
     7  * @compile/fail/ref=TwrOnNonResource.out -XDrawDiagnostics TwrOnNonResource.java
     8  */
    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     }
    23     /*
    24      * A close method, but the class is <em>not</em> Closeable or
    25      * AutoCloseable.
    26      */
    27     public void close() {
    28         throw new AssertionError("I'm not Closable!");
    29     }
    30 }

mercurial