Annotations on return-overridden methods also end up on bridge methods

Joel Borggrén-Franck joel.franck at oracle.com
Thu Nov 21 00:50:32 PST 2013


Hi Charlie,

On 21 Nov 2013, at 09:16, Charles Oliver Nutter <headius at headius.com> wrote:

> Hey there!
> 
> Sorry if this has been asked before, but I've been trying to get JRuby
> to compile properly on JDK8 javac and noticed a change.
> 
> JDK8 generates bridge methods in cases where a child class overrides a
> superclass method with a more specific return type. This may have been
> present in JDK7 and lower, I'm not sure.

I’m fairly sure these are being generated in 7 as well.

> What does seem to be different is that annotations attached to the
> hand-written override are also being attached to the bridge method.


> I'm not arguing that this is correct or incorrect behavior...merely
> that it is a change, and it may bite others the same way it has bitten
> us. I have patched our stub generator to skip bridge methods, but it
> feels kinda wrong.

I think this is a javac bug. I’ll dig around a bit and see what I find.

Thanks for the report!

cheers
/Joel


More information about the compiler-dev mailing list