users@hk2.java.net

ContractsProvided not provided for instance binding?

From: buko <buko_at_chiubarobot.com>
Date: Tue, 13 May 2014 06:46:22 -0400

https://java.net/jira/browse/HK2-176 has been fixed, which is great, but
there seems to be a problematic edge-case.

It seems if I do:

bind(MyConfiguration.class);

Then @ContractsProvided on MyConfiguration will be honored and it'll be
bound on the correct contracts. If, on the other hand, I do:

bind(new MyConfiguration("test1"));

Then @ContractsProvided is not honored. I must manually go back and add the
'to(Contract)' calls.

Why the difference? Is this a bug or expected behavior? It seems strange
that newing up an instance directly would somehow disable the contract
discovery.