Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Patch
Description
Groovy should ignore bridge methods.
This eliminates redundant method calls, although that isn't why
I need it.
My primary reason for this change is bit unusual; I've got a little
byte code post processor to inject synthetic bridge methods
to help me evolve code without breaking existing binaries,
<http://bridge-method-injector.infradna.com/>, and as a part of this
I generate a bridge method whose return type is narrower, instead of
wider.
That is, whereas normally bridge methods are as follows:
interface Base { Object foo(); } class Impl implements Base { String foo() {...} // the above definition causes javac to insert the following // bridge method @Synthetic @Bridge Object foo() { return <String>foo(); } }
my byte code post processing would produce this:
class Impl /* no interface needed */ { Object foo() {...} @Synthetic @Bridge String foo() { return (String)<Object>foo(); } }
This works with javac, in the sense that it'll invoke "Object foo()", by preferring non-bridge methods for resolution.
Unfortunately, Grooovy doesn't discreminate against bridge methods, so it can end up calling "String foo()" depending on the exact implementation detail of the search.
This fix eliminates this issue by making Groovy ignore all bridge methods. Would you please please include this?
Attachments
Attachments
Issue Links
- relates to
-
GROOVY-11341 @CompileStatic: Compilation fails due to a synthetic bridge method in the subclass
- Closed