langtools/test/tools/javac/generics/inference/8164399/T8164399b.java
author mcimadamore
Thu, 25 Aug 2016 11:51:19 +0100
changeset 40594 8cbf5df9c503
permissions -rw-r--r--
8164399: inference of thrown variable does not work correctly Summary: Logic for inferring thrown variables should exclude non proper bounds as per JLS 18.1 Reviewed-by: vromero, dlsmith
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40594
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     1
/*
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     3
 * @bug 8164399
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     4
 * @summary inference of thrown variable does not work correctly
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     5
 * @compile/fail/ref=T8164399b.out -XDrawDiagnostics T8164399b.java
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     6
 */
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     7
class T8164399b<X extends Throwable> {
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     8
    <T extends Throwable> void m(Class<? super T> arg) throws T {}
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
     9
    <T extends X> void g() throws T {}
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    10
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    11
    void test() {
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    12
        m(RuntimeException.class); // ok
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    13
        m(Exception.class); // error
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    14
        m(Throwable.class); // ok
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    15
        m(java.io.Serializable.class); // error
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    16
        m(Object.class); // error
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    17
        m(Runnable.class); // error
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    18
        T8164399b<? super Exception> x = null;
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    19
        x.g(); // expected: ok; actual: error
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    20
    }
8cbf5df9c503 8164399: inference of thrown variable does not work correctly
mcimadamore
parents:
diff changeset
    21
}