Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguous methods mapped for the current request when compiler creates bridge methods #645

Closed
froque opened this Issue Nov 27, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@froque
Copy link
Contributor

froque commented Nov 27, 2018

I am having the following error: "Ambiguous methods mapped for the current request: ...."

This is caused by having an abstract class (Class1), with an abstract method extending AbstractRestResource, and a class (Class2) that extends Class1 and overrides the abstract method, but returns a different type (but still assignable).

In this situation, the compiler will create a synthetic bridge method.

In previous versions of the java compiler. the compiler would not copy the annotations to the bridge method, so no duplicated methods would be found. This was corrected in JDK-6695379 : Copy method annotations and parameter annotations to synthetic bridge methods.

Note: the eclipse compiler is still affected by this bug: Bug 495396 - Inherited annotations are not visible on bridge methods (JDK 6695379).

All this combined, the method loadAnnotatedMethods in class AbstractRestResource, will load both bridge and non-bridge methods, and will throw when selecting the most suitable method in selectMostSuitedMethod.

@solomax

This comment has been minimized.

Copy link
Contributor

solomax commented Nov 29, 2018

Hello @froque,
Shall this fix be merged into master (java11)?

@froque

This comment has been minimized.

Copy link
Contributor Author

froque commented Nov 29, 2018

@solomax yes, I can't see any reason not to do it.

@solomax

This comment has been minimized.

Copy link
Contributor

solomax commented Dec 1, 2018

Done!
Many thanks for the contribution!

@solomax solomax closed this Dec 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.