users@hk2.java.net

Hanging on Bad Descriptor

From: buko <buko_at_chiubarobot.com>
Date: Sat, 17 Aug 2013 20:01:49 -0400

In my quest to deal with dynamic components I tried to create a component Y
that was both a factory for X and was also bound to a contract as Y. This
would allow some resources to look up Y and set X and other resources to
simply inject X.

Turns out this is not a good thing. Creating a descriptor that's a Factory
will result with a DescriptorType=Provide. But when the factory goes to be
injected as a regular component the entire system simply hangs. (Presumably
some sort of uncaught class cast exception is happening.) Not exactly sure
why the system hangs but perhaps some checking could be done to prevent
this? If a factory provides a class that's not assignable to the required
type that sort of error could perhaps be detected and flagged during
resolution.