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

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/generics/6723444/T6723444.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,58 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 6723444
     1.7 + *
     1.8 + * @summary javac fails to substitute type variables into a constructor's throws clause
     1.9 + * @author Mark Mahieu
    1.10 + * @compile/fail/ref=T6723444_1.out -Xlint:-options -source 7 -XDrawDiagnostics T6723444.java
    1.11 + * @compile/fail/ref=T6723444_2.out -XDrawDiagnostics T6723444.java
    1.12 + *
    1.13 + */
    1.14 +public class T6723444 {
    1.15 +
    1.16 +    static class Foo<X extends Throwable> {
    1.17 +        Foo() throws X {}
    1.18 +    }
    1.19 +
    1.20 +    <X extends Throwable> T6723444()
    1.21 +        throws X {}
    1.22 +
    1.23 +    <X extends Throwable> T6723444(Foo<X> foo)
    1.24 +        throws X {}
    1.25 +
    1.26 +    <X1 extends Throwable, X2 extends Throwable> T6723444(Foo<X1> foo, int i)
    1.27 +        throws X1, X2 {}
    1.28 +
    1.29 +    public static void main(String[] args) throws Exception {
    1.30 +
    1.31 +        // the following 8 statements should compile without error
    1.32 +
    1.33 +        Foo<Exception> exFoo = new Foo<Exception>();
    1.34 +        exFoo = new Foo<Exception>() {};
    1.35 +
    1.36 +        new<Exception> T6723444();
    1.37 +        new<Exception> T6723444() {};
    1.38 +        new T6723444(exFoo);
    1.39 +        new T6723444(exFoo) {};
    1.40 +        new<Exception, Exception> T6723444(exFoo, 1);
    1.41 +        new<Exception, Exception> T6723444(exFoo, 1) {};
    1.42 +
    1.43 +        // the remaining statements should all raise an
    1.44 +        // unreported exception error
    1.45 +
    1.46 +        new T6723444(exFoo, 1);
    1.47 +        new T6723444(exFoo, 1) {};
    1.48 +
    1.49 +        Foo<Throwable> thFoo = new Foo<Throwable>();
    1.50 +        thFoo = new Foo<Throwable>() {};
    1.51 +
    1.52 +        new<Throwable> T6723444();
    1.53 +        new<Throwable> T6723444() {};
    1.54 +        new T6723444(thFoo);
    1.55 +        new T6723444(thFoo) {};
    1.56 +        new T6723444(thFoo, 1);
    1.57 +        new T6723444(thFoo, 1) {};
    1.58 +        new<Throwable, Throwable> T6723444(thFoo, 1);
    1.59 +        new<Throwable, Throwable> T6723444(thFoo, 1) {};
    1.60 +    }
    1.61 +}

mercurial