test/tools/javac/TryWithResources/ResourceInterface.java

Mon, 02 Aug 2010 13:35:39 -0700

author
darcy
date
Mon, 02 Aug 2010 13:35:39 -0700
changeset 622
38e2c23309f1
parent 0
959103a6100f
permissions
-rw-r--r--

6971877: Project Coin: improve semantics of suppressed exceptions in try-with-resources
Reviewed-by: jjb

     1 /*
     2  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 6970833
    27  * @author Maurizio Cimadamore
    28  * @summary Try-with-resource implementation throws an NPE during Flow analysis
    29  * @compile/fail/ref=ResourceInterface.out -XDrawDiagnostics ResourceInterface.java
    30  */
    32 class ResourceInterface {
    33     public void test1() {
    34         try(Resource1 r1 = null) { }
    35     }
    37     public void test2() {
    38         try(Resource2 r2 = null) { }
    39     }
    41     static class E1 extends Exception {}
    43     static class E2 extends Exception {}
    46     interface C1 extends AutoCloseable {
    47        void close() throws E1;
    48     }
    50     interface C2 extends AutoCloseable {
    51        void close() throws E2;
    52     }
    54     interface C3 extends AutoCloseable {
    55        void close() throws E2, E1;
    56     }
    58     static interface Resource1 extends C1, C2 {}
    60     static interface Resource2 extends C1, C3 {}
    61 }

mercurial