langtools/test/tools/javac/TryWithResources/T7164542.java
author sundar
Fri, 11 May 2012 20:06:00 +0530
changeset 12716 5a41387068a8
permissions -rw-r--r--
7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12716
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     1
/*
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     4
 *
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     8
 *
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    13
 * accompanied this code).
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    14
 *
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    18
 *
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    21
 * questions.
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    22
 */
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    23
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    24
/*
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    25
 * @test
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    26
 * @bug 7164542
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    27
 * @summary try-with-resources: problem with intersection types
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    28
 * @compile T7164542.java
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    29
 */
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    30
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    31
public class T7164542 {
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    32
    public static <S extends Readable & AutoCloseable,
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    33
                       T extends Appendable & AutoCloseable>
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    34
    void copy(S s, T t, int size) throws Exception {
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    35
        /*
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    36
         * compiler used to fail here with:
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    37
         *     symbol:   method close()
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    38
         *     location: interface Readable
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    39
         *     Fatal Error: Unable to find method close
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    40
         */
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    41
        try (S src = s; T trg = t) {
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    42
        }
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    43
    }
5a41387068a8 7166990: java/compiler Inherited interfaces using generics sometimes looses the generic type
sundar
parents:
diff changeset
    44
}