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

Clarify inheritance semantics of annotations ProviderType and ConsumerType #643

Open
kwin opened this issue Nov 25, 2023 · 4 comments
Open

Comments

@kwin
Copy link

kwin commented Nov 25, 2023

Currently it is not clear from the javadoc of either ProviderType or ConsumerType which role annotation wins in case multiple ones apply (from the same package).

According to Bnd it is nearest wins, so in case you have class A extending B. And B extending C, the role of B overwrites the role of C (i.e. if C is marked as ProviderType but B is not having any role annotation at all it is assumed to be the default (i.e. ConsumerType) and A has a broad import-package version range).

Also if you have A both extending B as well as implementing Z and Z is a ProviderType, the ProviderType role wins (only relevant if Z and B are located in the same package).

@juergen-albert
Copy link
Contributor

juergen-albert commented Dec 6, 2023

Also if you have A both extending B as well as implementing Z and Z is a ProviderType, the ProviderType role wins (only relevant if Z and B are located in the same package).

@kwin We discussed the whole thing for half an hour and have some ideas. Just to help us along a bit: Can you provide a small dummy class example to make this easier to grasp? the issue

@juergen-albert
Copy link
Contributor

According to Bnd it is nearest wins, so in case you have class A extending B. And B extending C, the role of B overwrites the role of C (i.e. if C is marked as ProviderType but B is not having any role annotation at all it is assumed to be the default (i.e. ConsumerType) and A has a broad import-package version range).

The Annotations are not marked with @Inherited and thus the extending classes/interfaces don't know about the original annotation. By the default they thus become ContsumerType if not marked otherwise.

It would make sense to mention this in the javadoc.

kwin added a commit to kwin/providerconsumerexample that referenced this issue Dec 6, 2023
@kwin
Copy link
Author

kwin commented Dec 6, 2023

I added an example with README in https://github.com/kwin/providerconsumerexample which outlines the inconsistencies here.

@bjhargrave
Copy link
Member

There is no inheritance for these annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants