-
Notifications
You must be signed in to change notification settings - Fork 82
Avoid generating properties based on synthetic bridge methods #106
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
Conversation
My company's corporate CLA should be coming shortly -- they've agreed to sign it. |
* </ul> | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
private static <T> Class<T> reorderBridgeMethodFirst(Class<T> clazz, final String methodName) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love feedback if there is an easier way of doing this. I'm not very familiar with ASM, but I couldn't find any simpler APIs that let me reorder definitions within the class file.
This PR should be update to merge from https://github.com/bazaarvoice/jackson-modules-base/tree/bridge-methods |
Looks good wrt fix; test looks impressive but unfortunately I can not really say whether there might be an easier way. But one quick question first: wouldn't this make sense to merge against 2.12, or is there specific reason it's for master? |
Similar to #102, I would like like this bug fix to go into Please advise if you would like me to recreate this PR from the BV repo against |
I think that as per my comments on #102, this too can go in 2.11. |
Closing this in favor of #110 which targets 2.11 |
Problem
Java 5 supports covariant return types, which if overridden cause the compiler to generate "bridge" methods: https://stackoverflow.com/questions/14694852/can-overridden-methods-differ-in-return-type
These methods appear in
Class.getDeclaredMethods()
and if they happen to appear before the true non-bridge method, then they can causeBeanBuilder
either to:On my machine (Java 1.8.0_181-b13 on Mac), the failing test cases produce two distinct errors:
Solution
Skip over all synthetic and bridge methods as is done in databind's
AnnotatedMethodCollector
.