Throws clause of default constructor
Alex Buckley
alex.buckley at oracle.com
Mon Oct 27 21:43:50 UTC 2014
Looks like a javac bug when the thrown type is a type variable.
If A's ctor is simply "A() throws Throwable {}", then JDK8 javac reports
the error for B's default ctor regardless of -source version.
But make A's ctor generic and throw the type variable, and JDK8 javac
only reports the error for B with -source 1.7 and below.
In fact, javac cares whether T extends {Throwable,Exception} versus a
subclass of Exception. If T extends a checked exception type like
java.io.IOException, then JDK8 javac actually reports the error for B
regardless of -source version.
(All this on JDK8u25.)
Alex
On 10/27/2014 1:53 PM, John Spicer wrote:
> This case gets an error with javac 7 and javac 8 with -source 1.7, but is accepted by javac 8 in normal mode.
>
> I wasn't able to find the JLS change that corresponds to this.
>
> Any pointers would be appreciated.
>
> Thanks,
>
> John.
>
> class A {
> <T extends Throwable> A() throws T {}
> }
>
> class B extends A {}
>
More information about the compiler-dev
mailing list