langtools/test/tools/javac/TryWithResources/T7022711.java
author jlahoda
Wed, 09 Dec 2015 14:26:56 +0100
changeset 34565 627464b87753
parent 8620 0b04e5235f25
permissions -rw-r--r--
8080641: JEP-JDK-8042880 : Implement new tests on Project Coin Summary: A set of tests using t-w-r as variable in different positive and negative constructions Reviewed-by: abuckley, darcy, jlahoda, sadayapalam Contributed-by: sergei.pikalev@oracle.com

/*
 * @test /nodynamiccopyright/
 * @bug 7022711
 * @summary compiler crash in try-with-resources
 * @compile/fail/ref=T7022711.out -XDrawDiagnostics T7022711.java
 */

import java.io.*;

class T7022711 {
    public static void main (String args[]) throws Exception {
        // declared resource
        try (DataInputStream is = new DataInputStream(new FileInputStream("x"))) {
            while (true) {
                is.getChar();  // method not found
            }
        } catch (EOFException e) {
        }

        // resource as variable
        DataInputStream is = new DataInputStream(new FileInputStream("x"));
        try (is) {
            while (true) {
                is.getChar();  // method not found
            }
        } catch (EOFException e) {
        }
    }
}