Fri, 02 Nov 2012 14:35:57 -0700
7169362: JDK8: Write compiler tests for repeating annotations for JDK8
Reviewed-by: darcy, jjg
Contributed-by: sonali.goel@oracle.com
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.out -XDrawDiagnostics T6723444.java
8 *
9 */
10 public class T6723444 {
12 static class Foo<X extends Throwable> {
13 Foo() throws X {}
14 }
16 <X extends Throwable> T6723444()
17 throws X {}
19 <X extends Throwable> T6723444(Foo<X> foo)
20 throws X {}
22 <X1 extends Throwable, X2 extends Throwable> T6723444(Foo<X1> foo, int i)
23 throws X1, X2 {}
25 public static void main(String[] args) throws Exception {
27 // the following 8 statements should compile without error
29 Foo<Exception> exFoo = new Foo<Exception>();
30 exFoo = new Foo<Exception>() {};
32 new<Exception> T6723444();
33 new<Exception> T6723444() {};
34 new T6723444(exFoo);
35 new T6723444(exFoo) {};
36 new<Exception, Exception> T6723444(exFoo, 1);
37 new<Exception, Exception> T6723444(exFoo, 1) {};
39 // the remaining statements should all raise an
40 // unreported exception error
42 new T6723444(exFoo, 1);
43 new T6723444(exFoo, 1) {};
45 Foo<Throwable> thFoo = new Foo<Throwable>();
46 thFoo = new Foo<Throwable>() {};
48 new<Throwable> T6723444();
49 new<Throwable> T6723444() {};
50 new T6723444(thFoo);
51 new T6723444(thFoo) {};
52 new T6723444(thFoo, 1);
53 new T6723444(thFoo, 1) {};
54 new<Throwable, Throwable> T6723444(thFoo, 1);
55 new<Throwable, Throwable> T6723444(thFoo, 1) {};
56 }
57 }