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

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

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

mercurial