users@hk2.java.net

Re: Use of ContractsProvided? Indicating a Contract with an Annotation

From: John Wells <john.wells_at_oracle.com>
Date: Fri, 03 Jan 2014 15:05:52 -0500

No, you are right! I just looked at the code and @ContractsProvided is
not in fact honored in that case. I will enter a Jira and fix this:

https://java.net/jira/browse/HK2-176

On 1/3/2014 2:57 PM, John Wells wrote:
> I am surprised that @ContractsProvided does not do exactly what you
> seem to want. Do you have a test case? Because it seems like
> @ContractsProvided should work exactly how you say it should work...
>
> On 1/3/2014 1:04 AM, buko wrote:
>>
>> I have several interfaces in my domain and I'd like to provide
>> hk2-aware implementations of said interfaces. But I'd rather not
>> annotate such key domain interfaces with @Contract since it leaks
>> implementation into the domain. I had thought @ContractsProvided
>> provided a very nice way around this -- on the implementation class I
>> could explicitly indicate a certain interface was a contract an
>> provided by this component. But this does doesn't work at all. It
>> seems @ContractProvided still requires the actual interface to be
>> marked as a @Contract.
>>
>> Maybe ContractProvided is not the right way to do this but how can I
>> indicate a certain interface is supplied by a component via an
>> annotation? This stems from a strong desire to be able just use
>> addActiveDescriptor(Component.class) in binders and not have to use
>> explicit bind syntax.
>