-
Notifications
You must be signed in to change notification settings - Fork 82
Avoid generating implementations of synthetic bridge methods #110
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
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.module.mrbean.AbstractTypeMaterializer.MyClassLoader; | ||
import org.objectweb.asm.AnnotationVisitor; |
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.
In master, the package name has changed to net.bytebuddy.jar.asm
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.
Yes, we switched from Asm to ByteBuddy for 3.0... for tests we could still also include Asm unless you wanted to write alt implementation for BB.
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.
#106 has the ByteBuddy-based implementation for master. Migrating it back to 2.11 mostly just required changing the package name for the imports because I wasn't using any of the higher-level ByteBuddy constructs.
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.
Looks like changes I made prevent automatic merge; will merge manually due to it being one small change plus new test file. |
This PR is equivalent to #106 but targets
2.11
instead. The fix (if you wish to cherry-pick separately) is in d3a84d7.Also: To simplify the test case syntax, this PR upgrades the test sources for the MrBean module to Java 8, by cherry-picking the same commit 286b5d9 from PR 109.
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
.