langtools/test/tools/javac/generics/inference/CheckNoTimeoutException.java
author sadayapalam
Mon, 07 Mar 2016 18:49:02 +0530
changeset 36278 f74f056dc069
permissions -rw-r--r--
8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl Summary: Before computing intersection of thrown types, javac must make sure type variables come from the same set. Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36278
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     1
/*
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     4
 *
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     8
 *
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    13
 * accompanied this code).
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    14
 *
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    18
 *
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    21
 * questions.
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    22
 */
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    23
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    24
/**
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    25
 * @test
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    26
 * @bug 8148930
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    27
 * @summary Verify that there is no spurious unreported exception error.
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    28
 * @modules java.sql
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    29
 * @compile CheckNoTimeoutException.java
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    30
 */
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    31
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    32
import java.util.Collection;
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    33
import java.util.List;
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    34
import java.util.ArrayList;
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    35
import java.util.concurrent.TimeoutException;
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    36
import java.io.*;
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    37
import java.sql.SQLException;
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    38
import java.sql.SQLTransientException;
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    39
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    40
class CheckNoTimeoutException {
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    41
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    42
    interface V {List<?> foo(List<String> arg) throws EOFException, SQLException, TimeoutException;}
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    43
    interface U {Collection foo(List<String> arg) throws IOException, SQLTransientException;}
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    44
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    45
    //SAM type ([List<String>], List<String>/List, {EOFException, SQLTransientException})
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    46
    interface UV extends U, V {}
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    47
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    48
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    49
    private static List<String> strs = new ArrayList<String>();
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    50
    void methodUV(UV uv) {
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    51
        System.out.println("methodUV(): SAM type interface UV object instantiated: " + uv);
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    52
        try{
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    53
            System.out.println("result returned: " + uv.foo(strs));
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    54
        }catch(EOFException e){
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    55
            System.out.println(e.getMessage());
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    56
        }catch(SQLTransientException ex){
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    57
            System.out.println(ex.getMessage());
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    58
        }
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    59
    }
f74f056dc069 8148930: Incorrect erasure of exceptions in override-equivalent dual interface impl
sadayapalam
parents:
diff changeset
    60
}