Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Ambiguous methods mapped for the current request when compiler creates bridge methods #645
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.