For some reason I believe the spec specifically says that Object should not be in the list of types, which I believe is why your plain old java example isn't valid.
Joe On Sat, Jul 6, 2013 at 6:57 AM, Arne Limburg <[email protected]>wrote: > Hi Romain, > > > In plain old java the assignment does not work either: > > public class MyClass<T> > { > ArrayList<T> myTList = ... > ArrayList<String> myStringList = myTList; > } > > does not work... > > And if we have an injection point > > @Inject String myString; > > and a Producer > > @Produces Object myObject; > > then they don't match. > > So why should it match with generics? > > Cheers, > Arne > > Am 06.07.13 12:50 schrieb "Romain Manni-Bucau" unter > <[email protected]>: > > >So i confirm what i said, ArrayList<T> can be for String, Foo....so i > >think > >classes should follow it, just match what i expect since i could do it in > >plain old java > >Le 6 juil. 2013 10:18, "Arne Limburg" <[email protected]> a > >écrit : > > > >> 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 > >> <[email protected]>: > >> > >> >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" <[email protected]> > 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 > >> >> > >> > >> > >
