-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
docs: Clarify if annotations can also be inherited from interfaces #271
Comments
Yes, annotation inheritance works with classes and interfaces both. PR for clarification would be welcome! |
Thanks. It would be nice to also state what happens if there is multiple-inheritance conflict. Is there stable order of resolution or is it JVM dependent etc? |
I think there are also some traps when using interfaces, e.g. if you write
you probably mean to provide a concrete implementation for it. However it will be inherited by any concrete classes implementing the interfaces so this will fail:
above use case has to be addressed via a module and |
Right. That is definitely one possible concern since all "flattening" of Jackson annotations occurs without knowledge of semantics. And in case of |
@cowtowncoder could you also clarify this? I feel this information should be included in the doc. Then I can try to make a PR to improve the documentation. |
@jakub-bochenski Ok, so, order used for For super classes ordering is not problematic: overrides work as expected since Java is single-inheritance and precedence is based on that. On a given class, predence between base class and extended interfaces is such that base-class has lower precedence than interfaces. So:
Annotations from Annotations from A and B have precedence such that the one seen first (given by JDK) has lowest precedence, next one overrides that, and last one has highest precedence. I hope this helps. |
It's not clear if you can also inherit the annotations from interfaces and/or interface methods
The text was updated successfully, but these errors were encountered: