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

Thu, 27 Aug 2009 11:08:27 -0700

author
jjg
date
Thu, 27 Aug 2009 11:08:27 -0700
changeset 384
ed31953ca025
parent 229
03bcd66bd8e7
child 611
4172cfff05f0
permissions
-rw-r--r--

6875336: some tests should use /nodynamiccopyright/
Reviewed-by: darcy

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

mercurial