test/tools/javac/generics/6723444/T6723444.java

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 3938
93012e2a5d1d
parent 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset eb6ee6a5f2fe

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 6723444
     4  *
     5  * @summary javac fails to substitute type variables into a constructor's throws clause
     6  * @author Mark Mahieu
     7  * @compile/fail/ref=T6723444_1.out -Xlint:-options -source 7 -XDrawDiagnostics T6723444.java
     8  * @compile/fail/ref=T6723444_2.out -XDrawDiagnostics T6723444.java
     9  *
    10  */
    11 public class T6723444 {
    13     static class Foo<X extends Throwable> {
    14         Foo() throws X {}
    15     }
    17     <X extends Throwable> T6723444()
    18         throws X {}
    20     <X extends Throwable> T6723444(Foo<X> foo)
    21         throws X {}
    23     <X1 extends Throwable, X2 extends Throwable> T6723444(Foo<X1> foo, int i)
    24         throws X1, X2 {}
    26     public static void main(String[] args) throws Exception {
    28         // the following 8 statements should compile without error
    30         Foo<Exception> exFoo = new Foo<Exception>();
    31         exFoo = new Foo<Exception>() {};
    33         new<Exception> T6723444();
    34         new<Exception> T6723444() {};
    35         new T6723444(exFoo);
    36         new T6723444(exFoo) {};
    37         new<Exception, Exception> T6723444(exFoo, 1);
    38         new<Exception, Exception> T6723444(exFoo, 1) {};
    40         // the remaining statements should all raise an
    41         // unreported exception error
    43         new T6723444(exFoo, 1);
    44         new T6723444(exFoo, 1) {};
    46         Foo<Throwable> thFoo = new Foo<Throwable>();
    47         thFoo = new Foo<Throwable>() {};
    49         new<Throwable> T6723444();
    50         new<Throwable> T6723444() {};
    51         new T6723444(thFoo);
    52         new T6723444(thFoo) {};
    53         new T6723444(thFoo, 1);
    54         new T6723444(thFoo, 1) {};
    55         new<Throwable, Throwable> T6723444(thFoo, 1);
    56         new<Throwable, Throwable> T6723444(thFoo, 1) {};
    57     }
    58 }

mercurial