test/tools/javac/TryWithResources/BadTwr.java

Mon, 26 Mar 2012 15:28:22 +0100

author
mcimadamore
date
Mon, 26 Mar 2012 15:28:22 +0100
changeset 1238
e28a06a3c5d9
parent 0
959103a6100f
permissions
-rw-r--r--

7151492: Encapsulate check logic into Attr.ResultInfo
Summary: ResultInfo class should be used to make attribution code transparent w.r.t. check logic being used
Reviewed-by: jjg, dlsmith

     1 /*
     2  * @test  /nodynamiccopyright/
     3  * @bug 6911256 6964740
     4  * @author Joseph D. Darcy
     5  * @summary Verify bad TWRs don't compile
     6  * @compile/fail -source 6 TwrFlow.java
     7  * @compile/fail/ref=BadTwr.out -XDrawDiagnostics BadTwr.java
     8  */
    10 public class BadTwr implements AutoCloseable {
    11     public static void main(String... args) {
    12         // illegal repeated name
    13         try(BadTwr r1 = new BadTwr(); BadTwr r1 = new BadTwr()) {
    14             System.out.println(r1.toString());
    15         }
    17         // illegal duplicate name of method argument
    18         try(BadTwr args = new BadTwr()) {
    19             System.out.println(args.toString());
    20             final BadTwr thatsIt = new BadTwr();
    21             thatsIt = null;
    22         }
    24         try(BadTwr name = new BadTwr()) {
    25             // illegal duplicate name of enclosing try
    26             try(BadTwr name = new BadTwr()) {
    27                 System.out.println(name.toString());
    28             }
    29         }
    31     }
    33     public void close() {
    34         ;
    35     }
    36 }

mercurial