Hi

It looks ambiguous to me
Le 6 juil. 2013 20:16, "Arne Limburg" <arne.limb...@openknowledge.de> a
écrit :

> Anyway,
> I took a look into the CDI 1.1 TCK, which has a quite interesting
> deployment scenario with generics:
>
> public class Baz<T> {
> }
>
> public class Qux extends Baz<String> {
> }
>
>
>
> @Vetoed
> public class Bar<T1, T2> {
>   @Inject
>   private Baz<T1> baz;
>   @Inject
>   private Baz<List<T2>> t2BazList;
> }
>
>
>
> @RequestScoped
> public class Foo extends Bar<String, Qux> {
> }
>
>
> public class Producer {
>   @Produces
>   @Amazing
>   public String produceString() {
>     return "ok";
>   }
>
>   @Produces
>   public String[] produceStringArray() {
>     return new String[0];
>   }
>
>   @Produces
>   public Baz<Baz<Qux>> produceBazBazQux() {
>     return new Baz();
>   }
> }
>
> The class Bar has some more injection points, but that does not matter.
> Due to the TCK this deployment should work, but I don't know how.
> Question (it is basically the question we are discussing here): Is Baz a
> Bean (I suppose so) and may it be injected into the second injection point
> of Bean Foo in class Bar?
> - If yes, it also should be injected into the first injection point,
> right? This would lead to an AmbiguousResolutionException since Qux could
> also be injected into the first injection point.
> - If no, the deployment should fail with a UnsatisfiedResolutionException
> since there is no Bean that can be injected into that injection point.
>
> WDYT?
>
> If noone can shed light into this, I will cross-post this mail to the
> cdi-dev list.
>
> Cheers,
> Arne
>
>
>
> Am 06.07.13 19:00 schrieb "Mark Struberg" unter <strub...@yahoo.de>:
>
> >I thought about this a bit now. This is a bit of a mixed bag.
> >
> >Another pov is:
> >
> >ArrayList<T> which gets erased to ArrayList<Object> should be treated as
> >ArrayList.
> >
> >Now for the question: does a Producer for ArrayList also get used for an
> >InjectionPoint of ArrayList<String>?
> >In CDI 1.0 only the other way around was specified. We had this
> >discussion with the Weld guys and also had this code in some CDI
> >Extensions.
> >
> >Not an easy topic indeed.
> >
> >LieGrue,
> >strub
> >
> >
> >
> >
> >----- Original Message -----
> >From: Arne Limburg <arne.limb...@openknowledge.de>
> >To: "dev@openwebbeans.apache.org" <dev@openwebbeans.apache.org>
> >Cc:
> >Sent: Saturday, 6 July 2013, 10:18
> >Subject: Re: OWB and generics
> >
> >Forgot to mention that T is an unbound type variable at class level:
> >
> >
> >public class MethodTypeProduces1<T>
> >
> >and there is no subclass of MethodTypeProduces1
> >
> >
> >Am 06.07.13 10:12 schrieb "Romain Manni-Bucau" unter
> ><rmannibu...@gmail.com>:
> >
> >>Wait, not sure google ate a part of the code or not but if a <T> then T
> >>can
> >>be String (like ArrayList itself)
> >>Le 6 juil. 2013 09:18, "Arne Limburg" <arne.limb...@openknowledge.de> a
> >>écrit :
> >>
> >>> Hi,
> >>>
> >>> I am currently struggling with the handling of generics in OWB, because
> >>> CDI 1.1 TCK requires us to be much more clever than we are now in this
> >>>area.
> >>> However I stumbled about a test in our test-suite that seems to be
> >>>wrong
> >>> to me, but I would like to have another opinion.
> >>> With my local implementation of the generic handling (which is much
> >>>better
> >>> than the one in trunk) the following tests fails:
> >>> MethodProducer1Test.testPersonProducer
> >>>
> >>> Basically it tests if an ArrayList with an unbound type variable is
> >>> injectable into an injection point of type ArrayList<String>:
> >>>
> >>>     @Produces @Dependent @Named("ProMethodParameterized3")
> >>>
> >>>     ArrayList<T> methodPT3() {...}
> >>>
> >>> and
> >>>
> >>>     @Inject ArrayList<String> pt3;
> >>>
> >>> Reading 5.2.4 of the CDI 1.1 spec (the fourth bullet point) I would
> >>> suggest that this should lead to an error since String is not
> >>>assignable
> >>> from Object (which is the upper bound of T).
> >>>
> >>>
> >>> WDYT?
> >>>
> >>>
> >>> Cheers,
> >>>
> >>> Arne
> >>>
> >
>
>

Reply via email to