<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif; color: rgb(0, 0, 0); ">
<div>
<div>Makes sense to me. So we have to revert the change of CDI-85?</div>
</div>
<div><br>
</div>
<div>Regards,</div>
<div>Arne</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">Von: </span>Marko Lukıa &lt;<a href="mailto:marko.luksa@gmail.com">marko.luksa@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Datum: </span>Dienstag, 16. Juli 2013 12:31<br>
<span style="font-weight:bold">An: </span>Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Cc: </span>&quot;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&quot; &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
<span style="font-weight:bold">Betreff: </span>Re: [cdi-dev] CDI and generics<br>
</div>
<div><br>
</div>
<div>
<div text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Looking at [1] again, I see the mistake now:<br>
<br>
while MediumClass is assignable to SmallClass, ArrayList&lt;MediumClass&gt; is NOT assignable to ArrayList&lt;SmallClass&gt; (this is a common mistake - see [2]).<br>
<br>
So, given the following:<br>
<pre style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">&gt;<i> public class C1&lt;T extends MediumClass&gt; {
</i>&gt;<i>  @Produces ... ArrayList&lt;T&gt; m1()
</i>&gt;<i> 
</i>&gt;<i> @Inject  ... ArrayList&lt;SmallClass&gt; s1;
</i>&gt;<i> @Inject  ... ArrayList&lt;BigClass&gt; b1;</i></pre>
s1 needs an object that is exactly an ArrayList&lt;SmallClass&gt; and b1 needs exactly ArrayList&lt;BigClass&gt;.<br>
<br>
The producer method is able to produce ArrayList&lt;MediumClass&gt; and ArrayList&lt;BigClass&gt;. It is NOT able to produce ArrayList&lt;SmallClass&gt;. Therefore s1 cannot be satisfied.<br>
<br>
The original wording in the CDI 1.0 spec was correct:<br>
&quot;<i>- the required type parameter is an actual type, the bean type parameter is a type variable and the actual type is assignable *to* the upper bound, if any, of the type variable</i>&quot;<br>
<br>
s1: the required type parameter is the actual type SmallClass, the bean type parameter is a type variable with upper bound MediumClass. The actual type is not assignable to the upper bound (SmallClass is not assignable to MediumClass), therefore s1 cannot be
 satisfied.<br>
<br>
b1: the required type parameter is the actual type BigClass, the bean type parameter is a type variable with upper bound MediumClass. The actual type IS assignable to the upper bound (BigClass is assignable to MediumClass), therefore b1 can be satisfied.<br>
<br>
[1] <a href="http://lists.jboss.org/pipermail/weld-dev/2010-August/002627.html">http://lists.jboss.org/pipermail/weld-dev/2010-August/002627.html</a><br>
[2] <a href="http://docs.oracle.com/javase/tutorial/java/generics/inheritance.html">
http://docs.oracle.com/javase/tutorial/java/generics/inheritance.html</a><br>
<br>
Marko<br>
<br>
On 16.7.2013 9:36, Romain Manni-Bucau wrote:<br>
</div>
<blockquote cite="mid:CACLE=7NpHsHTbP3BJx7wDC4uJbb9xMtpDtqt-L8M1Hcq72uazw@mail.gmail.com" type="cite">
no no, what i say is CDI could handle generic beans as template it would duplicate as many time as needed to match all instances. the same as for @Dependent but with the scope you want. there is no technical blocking point.
<div><br clear="all">
<div>
<div><i>Romain Manni-Bucau</i></div>
<div><i>Twitter: <a moz-do-not-send="true" href="https://twitter.com/rmannibucau" target="_blank">
@rmannibucau</a></i></div>
<div><i>Blog:&nbsp;</i><a moz-do-not-send="true" href="http://rmannibucau.wordpress.com/" target="_blank"><i>http://rmannibucau.wordpress.com/</i></a></div>
<div><i>LinkedIn:&nbsp;</i><font color="#0000ee"><i><u><a moz-do-not-send="true" href="http://fr.linkedin.com/in/rmannibucau" target="_blank">http://fr.linkedin.com/in/rmannibucau</a></u></i></font></div>
<div><i><span style="background-color:rgb(255,255,255)">Github:&nbsp;</span><a moz-do-not-send="true" href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a></i></div>
<div><br>
</div>
</div>
<br>
<br>
<div class="gmail_quote">2013/7/16 Marko Lukıa <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:marko.luksa@gmail.com" target="_blank">marko.luksa@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>Yes, you'd need an extension that registers multiple beans. But that's how it needs to be.
<br>
<br>
It's not sad. This simply can't work. If you inject the same instance into both @Inject List&lt;String&gt; stringList and @Inject List&lt;Integer&gt; integerList, then the user can do this:<br>
<br>
stringList.add(&quot;some string&quot;);<br>
integerList.add(15);<br>
for (String str : stringList) {<br>
&nbsp;&nbsp;&nbsp; System.out.println(str);<br>
}<br>
<br>
which would result in a ClassCastException, right?<span class="HOEnZb"><font color="#888888"><br>
<br>
Marko</font></span>
<div>
<div class="h5"><br>
<br>
On 16.7.2013 9:23, Romain Manni-Bucau wrote:<br>
</div>
</div>
</div>
<div>
<div class="h5">
<blockquote type="cite">hmm, and if you don't want a @Dependent? it is doable through an extension but not through declaration, that's sad IMO
<div><br clear="all">
<div>
<div><i>Romain Manni-Bucau</i></div>
<div><i>Twitter: <a moz-do-not-send="true" href="https://twitter.com/rmannibucau" target="_blank">
@rmannibucau</a></i></div>
<div><i>Blog:&nbsp;</i><a moz-do-not-send="true" href="http://rmannibucau.wordpress.com/" target="_blank"><i>http://rmannibucau.wordpress.com/</i></a></div>
<div><i>LinkedIn:&nbsp;</i><font color="#0000ee"><i><u><a moz-do-not-send="true" href="http://fr.linkedin.com/in/rmannibucau" target="_blank">http://fr.linkedin.com/in/rmannibucau</a></u></i></font></div>
<div><i><span style="">Github:&nbsp;</span><a moz-do-not-send="true" href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a></i></div>
<div><br>
</div>
</div>
<br>
<br>
<div class="gmail_quote">2013/7/16 Marko Lukıa <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:marko.luksa@gmail.com" target="_blank">marko.luksa@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>What Arne was concerned about is that we cannot inject the same instance into two different typed injection points. We can't have an object that is a list of strings and a list of integers at the same time. We would need such an object if we wanted to
 inject it into both @Inject List&lt;String&gt; and @Inject List&lt;Integer&gt;. <br>
<br>
What I pointed out is that CDI has this covered, as it requires all beans with a parameterized bean class to be dependent scoped and by definition not sharable across multiple injection points. CDI will create a _new instance_ for each injection point, therefore
 it actually can inject bean MyClass&lt;T&gt; into both @Inject MyClass&lt;String&gt; and @Inject MyClass&lt;Integer&gt;, since it injects two different instances. There is no need to have a custom extension and register MyClass&lt;T&gt; multiple times (as MyClass&lt;String&gt;, MyClass&lt;Integer&gt;,
 etc.). <br>
<br>
So this means the change at [1] was a mistake. <br>
<br>
[1] <a moz-do-not-send="true" href="https://github.com/cdi-spec/cdi/commit/b32243350ace6a0bba337f91a35f5fd05c151f14" target="_blank">
https://github.com/cdi-spec/cdi/commit/b32243350ace6a0bba337f91a35f5fd05c151f14</a><span><font color="#888888"><br>
<br>
Marko</font></span>
<div>
<div><br>
<br>
On 16.7.2013 7:17, Romain Manni-Bucau wrote:<br>
</div>
</div>
</div>
<div>
<div>
<blockquote type="cite">
<p>Hmm not sure i get the Dependent limit. Using a custom extension you'll register the same bean as many times as needed but using different values for parameters and the scope you want.</p>
<p>Why CDI wouldnt be able of it out of the box?</p>
<p>It is really something basic in 2013 and find really sad that's look so complicated. Please explain me what i'm missing if so.</p>
<div class="gmail_quote">Le 16 juil. 2013 00:15, &quot;Marko Lukıa&quot; &lt;<a moz-do-not-send="true" href="mailto:marko.luksa@gmail.com" target="_blank">marko.luksa@gmail.com</a>&gt; a écrit&nbsp;:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0
                                      .8ex;border-left:1px #ccc
                                      solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>Actually, it will never be the same instance, since all beans with a parameterized bean class must be @Dependent scoped.<br>
<br>
Marko<br>
<br>
On 15.7.2013 23:46, Arne Limburg wrote:<br>
</div>
<blockquote type="cite">
<div>No, I understood you right ;-)</div>
<div>In Java the same instance cannot be MyClass&lt;String&gt; and MyClass&lt;Integer&gt; at the same time.</div>
<div>We would do exactly that, if we had two injection points like</div>
<div>@Inject</div>
<div>MyClass&lt;String&gt; myStringClass;</div>
<div>@Inject</div>
<div>MyClass&lt;Integer&gt; myIntegerClass;</div>
<div>In plain java this could never be the same instances without heavy (compile-time) casting, thus this should not be the same instances in CDI.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Arne</div>
<div><br>
</div>
<span>
<div style="border-right:medium
                                              none;padding-right:0in;padding-left:0in;padding-top:3pt;text-align:left;font-size:11pt;border-bottom:medium
                                              none;font-family:Calibri;border-top:#b5c4df
                                              1pt
                                              solid;padding-bottom:0in;border-left:medium
                                              none">
<span style="font-weight:bold">Von: </span>Romain Manni-Bucau &lt;<a moz-do-not-send="true" href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Datum: </span>Montag, 15. Juli 2013 23:41<br>
<span style="font-weight:bold">An: </span>Arne Limburg &lt;<a moz-do-not-send="true" href="mailto:arne.limburg@openknowledge.de" target="_blank">arne.limburg@openknowledge.de</a>&gt;<br>
<span style="font-weight:bold">Cc: </span>Mark Struberg &lt;<a moz-do-not-send="true" href="mailto:struberg@yahoo.de" target="_blank">struberg@yahoo.de</a>&gt;, Martin Kouba &lt;<a moz-do-not-send="true" href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;,
 &quot;<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&quot; &lt;<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;<br>
<span style="font-weight:bold">Betreff: </span>Re: [cdi-dev] CDI and generics<br>
</div>
<div><br>
</div>
<div>
<div>hmm think you misunderstood what i said (sorry if it was unclear)
<div><br>
</div>
<div>basically my point was a generic bean or produced bean should be injectable everywhere so MyClass&lt;T&gt; should match @Inject MyClass&lt;String&gt;. In plain java we do: new MyClass&lt;String&gt;().</div>
<div><br clear="all">
<div>
<div><i>Romain Manni-Bucau</i></div>
<div><i>Twitter: <a moz-do-not-send="true" href="https://twitter.com/rmannibucau" target="_blank">
@rmannibucau</a></i></div>
<div><i>Blog:&nbsp;</i><a moz-do-not-send="true" href="http://rmannibucau.wordpress.com/" target="_blank"><i>http://rmannibucau.wordpress.com/</i></a></div>
<div><i>LinkedIn:&nbsp;</i><font color="#0000ee"><i><u><a moz-do-not-send="true" href="http://fr.linkedin.com/in/rmannibucau" target="_blank">http://fr.linkedin.com/in/rmannibucau</a></u></i></font></div>
<div><i><span>Github:&nbsp;</span><a moz-do-not-send="true" href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a></i></div>
<div><br>
</div>
</div>
<br>
<br>
<div class="gmail_quote">2013/7/15 Arne Limburg <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:arne.limburg@openknowledge.de" target="_blank">arne.limburg@openknowledge.de</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0
                                                      0
                                                      .8ex;border-left:1px
                                                      #ccc
                                                      solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div style="font-size:14px;font-family:Calibri,sans-serif">
<div>
<div>Hi Romain,</div>
</div>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">In plain old java the behavior would depend on where the type variable is declared.</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">See the following samples:</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">public class MyClass&lt;T&gt; {</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">&nbsp; &nbsp; List&lt;T&gt; myList = new ArrayList&lt;T&gt;();</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">&nbsp; &nbsp; List&lt;String&gt; myStringList = myList;</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">}</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">public class MyClass {</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">&nbsp; &nbsp; &lt;T&gt; List&lt;T&gt; myList() {</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; return new ArrayList&lt;T&gt;();</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">&nbsp; &nbsp; }</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">&nbsp; &nbsp; List&lt;String&gt; myStringList = myList();</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">}</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">The first example does not work and the second works.</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">And even, if you would access myList from outside, the first example just works, if you instantiate myClass with the type argument:</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">List&lt;String&gt; myStringList = new MyClass&lt;String&gt;().myList;</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">To transfer this to CDI: We would need an instance of Bean MyClass with MyClass&lt;String&gt; in the type closure. And we would have to do this for every type argument that can be found within the injection
 points, i.e., if we had the injection points</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">@Inject</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">MyClass&lt;String&gt; myStringClass;</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">@Inject</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">MyClass&lt;Integer&gt; myIntegerClass;</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">either the type closure of my class would have to contain MyClass&lt;String&gt; AND MyClass&lt;Integer&gt; or we would need to have different beans for both types. I think, we cannot do either.</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div style="font-size:14px;font-family:Calibri,sans-serif">I suggest to handle TypeVariables declared at class level different than TypeVariables declared at (producer-)method level. Thus we could handle Mark Strubergs case and leave the rest like it is in
 plain old java.</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<div><font style="font-size:14px" face="Calibri,sans-serif">I suggest to change the fourth bullet po</font>int of chapter 5.2.4:</div>
<div>&quot;the required type parameter is an actual type, the bean type parameter is a type variable that is declared at class level and the actual type is assignable from&nbsp;the upper bound of the type variable,&quot;</div>
<div>and add another bullet point:</div>
<div>&quot;the required type parameter is an actual type, the bean type parameter is a type variable that is declared at method level and the actual type is assignable to&nbsp;the upper bound of the type variable, or&quot;</div>
<div>And add a footnote: &quot;If no explicit upper bound is defined, the implicit upper bound java.lang.Object is assumed&quot;</div>
<div><br>
</div>
<div>BTW. Should we create a spec issue for that?</div>
<div><br>
</div>
<div>WDYT?</div>
<div>Regards,</div>
<div>Arne</div>
<div><br>
</div>
<div>P.S.: I don't think this is a backward compatibility issue, just because Weld and OpenWebBeans implemented it differently in the past. It just was not clear in 1.0 and is not in 1.1. The misleading part is the &quot;if any&quot; in the fourth bullet point. A TypeVariable
 ALWAYS has an upper bound. &quot;If no bound is given for a type variable, Object is&nbsp;assumed&quot; (Java Lang Spec 4.4)</div>
<div style="font-size:14px;font-family:Calibri,sans-serif"><br>
</div>
<span style="font-size: 14px; font-family: Calibri, sans-serif; ">
<div style="border-right:medium
                                                          none;padding-right:0in;padding-left:0in;padding-top:3pt;text-align:left;font-size:11pt;border-bottom:medium
                                                          none;font-family:Calibri;border-top:#b5c4df
                                                          1pt
                                                          solid;padding-bottom:0in;border-left:medium
                                                          none">
<span style="font-weight:bold">Von: </span>Romain Manni-Bucau &lt;<a moz-do-not-send="true" href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Datum: </span>Montag, 15. Juli 2013 07:55<br>
<span style="font-weight:bold">An: </span>Mark Struberg &lt;<a moz-do-not-send="true" href="mailto:struberg@yahoo.de" target="_blank">struberg@yahoo.de</a>&gt;<br>
<span style="font-weight:bold">Cc: </span>Martin Kouba &lt;<a moz-do-not-send="true" href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;, Arne Limburg &lt;<a moz-do-not-send="true" href="mailto:arne.limburg@openknowledge.de" target="_blank">arne.limburg@openknowledge.de</a>&gt;,
 &quot;<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&quot; &lt;<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;<br>
<span style="font-weight:bold">Betreff: </span>Re: [cdi-dev] CDI and generics<br>
</div>
<div>
<div>
<div><br>
</div>
<div>
<div>
<p style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">&#43;1, if we are no more aligned on something so simple in plain java we are useless i fear :(</p>
<p style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">(i used and saw it used in a lot of real apps)</p>
<p style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br>
</p>
<div>
<div><i>Romain Manni-Bucau</i></div>
<div><i>Twitter: <a moz-do-not-send="true" href="https://twitter.com/rmannibucau" target="_blank">
@rmannibucau</a></i></div>
<div><i>Blog:&nbsp;</i><a moz-do-not-send="true" href="http://rmannibucau.wordpress.com/" target="_blank"><i>http://rmannibucau.wordpress.com/</i></a></div>
<div><i>LinkedIn:&nbsp;</i><font color="#0000ee"><i><u><a moz-do-not-send="true" href="http://fr.linkedin.com/in/rmannibucau" target="_blank">http://fr.linkedin.com/in/rmannibucau</a></u></i></font></div>
<div><i><span>Github:&nbsp;</span><a moz-do-not-send="true" href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a></i></div>
<div><br>
</div>
</div>
<br>
<br>
<div class="gmail_quote">2013/7/14 Mark Struberg <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:struberg@yahoo.de" target="_blank">struberg@yahoo.de</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0
                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">
folks, this breaks backward compatibility<br>
<br>
<br>
In CDI 1.0 it was perfectly fine to do the following<br>
<br>
&nbsp;&nbsp;&nbsp; @Produces<br>
&nbsp;&nbsp;&nbsp; @Dependent<br>
&nbsp;&nbsp;&nbsp; public &lt;KEY, VALUE extends Serializable&gt; Cache&lt;KEY, VALUE&gt; getDefaultCache(InjectionPoint injectionPoint) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type ipType = injectionPoint.getType();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String cacheName = null;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ipType instanceof ParameterizedType) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ParameterizedType generic = (ParameterizedType) ipType;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type[] paramTypes = generic.getActualTypeArguments();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (paramTypes == null || paramTypes.length != 2) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new RuntimeException(&quot;illegal param types for generic type &quot; &#43; ipType);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (paramTypes[1] instanceof Class) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cacheName = ((Class) paramTypes[1]).getSimpleName();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cacheName = paramTypes[1].toString();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return getCache(cacheName);<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
<br>
<br>
usage:<br>
<br>
<br>
@Inject<br>
private Cache&lt;String, IdmUser&gt; userCache;<br>
<br>
<br>
With your new interpretation you basically trash this, right?<br>
For having a generic producer you would need to create a distinct producer method for each and every usage. This just doesn't work out in practice...<br>
<div><br>
<br>
<br>
LieGrue,<br>
strub<br>
<br>
<br>
<br>
<br>
<br>
----- Original Message -----<br>
From: Martin Kouba &lt;<a moz-do-not-send="true" href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;<br>
</div>
<div>To: Arne Limburg &lt;<a moz-do-not-send="true" href="mailto:arne.limburg@openknowledge.de" target="_blank">arne.limburg@openknowledge.de</a>&gt;<br>
Cc: &quot;<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&quot; &lt;<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;<br>
Sent: Wednesday, 10 July 2013, 14:01<br>
Subject: Re: [cdi-dev] CDI and generics<br>
<br>
</div>
<div>
<div>No, it's not necessary. We'll fix this within CDITCK-349 [1]. Leave a<br>
comment if you wish :-)<br>
<br>
Thanks<br>
Martin<br>
<br>
[1]<br>
<a moz-do-not-send="true" href="https://issues.jboss.org/browse/CDITCK-349" target="_blank">https://issues.jboss.org/browse/CDITCK-349</a><br>
<br>
<br>
Dne 10.7.2013 13:52, Arne Limburg napsal(a):<br>
&gt; OK, so shall I create a TCK issue for that?<br>
&gt;<br>
&gt;<br>
&gt; Cheers,<br>
&gt; Arne<br>
&gt;<br>
&gt; Am 10.07.13 13:50 schrieb &quot;Martin Kouba&quot; unter &lt;<a moz-do-not-send="true" href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;:<br>
&gt;<br>
&gt;&gt; Hi Arne,<br>
&gt;&gt;<br>
&gt;&gt; I think so (except the required type is Baz&lt;List&lt;Qux&gt;&gt;) - there is no<br>
&gt;&gt; bean with assignable bean type for this IP (according to CDI 1.1 rules<br>
&gt;&gt; of course).<br>
&gt;&gt;<br>
&gt;&gt; Martin<br>
&gt;&gt;<br>
&gt;&gt; Dne 10.7.2013 13:16, Arne Limburg napsal(a):<br>
&gt;&gt;&gt; Hi Martin,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; So, which bean should be injected into<br>
&gt;&gt;&gt; @Inject<br>
&gt;&gt;&gt;&nbsp; &nbsp; &nbsp;private Baz&lt;List&lt;T2&gt;&gt; t2BazList;<br>
&gt;&gt;&gt; ?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Baz&lt;T&gt; is also not assignable to Baz&lt;List&lt;String&gt;&gt;, because List&lt;String&gt;<br>
&gt;&gt;&gt; is also not assignable from Object.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Am I right, that the test should throw an<br>
&gt;&gt;&gt; UnsatisfiedResolutionException?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Cheers,<br>
&gt;&gt;&gt; Arne<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Am 08.07.13 12:17 schrieb &quot;Martin Kouba&quot; unter &lt;<a moz-do-not-send="true" href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Re Arne's question:<br>
&gt;&gt;&gt;&gt; Yes, Baz is a managed bean and AmbiguousResolutionException should not<br>
&gt;&gt;&gt;&gt; be thrown because Qux is not a managed bean (doesn't have a public<br>
&gt;&gt;&gt;&gt; no-arg constructor).<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Re Marko's findings:<br>
&gt;&gt;&gt;&gt; Yes, the TCK assertions are not up to date and Baz&lt;T&gt; is not assignable<br>
&gt;&gt;&gt;&gt; to Baz&lt;String&gt;, because String is not assignable from Object (no bound<br>
&gt;&gt;&gt;&gt; is defined -&gt; Object is assumed; see JSL 4.4). So I confirm a TCK<br>
&gt;&gt;&gt;&gt; issue.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; IMO this would deserve a proper cleanup...<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Martin<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Dne 8.7.2013 01:22, Marko Lukıa napsal(a):<br>
&gt;&gt;&gt;&gt;&gt; I'd say it's a bug. While Baz indeed is a managed bean, it shouldn't<br>
&gt;&gt;&gt;&gt;&gt; be<br>
&gt;&gt;&gt;&gt;&gt; injected into injection point with type Baz&lt;String&gt; nor<br>
&gt;&gt;&gt;&gt;&gt; Baz&lt;List&lt;Qux&gt;&gt;.<br>
&gt;&gt;&gt;&gt;&gt; So I believe you're right in saying that this test should fail with<br>
&gt;&gt;&gt;&gt;&gt; UnsatisfiedResolutionException.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; There was a change made to the spec way back in 2010 (see [1]), but<br>
&gt;&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt; TCK apparently wasn't updated then. I've filed an issue in the TCK<br>
&gt;&gt;&gt;&gt;&gt; jira<br>
&gt;&gt;&gt;&gt;&gt; [2].<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; The problem isn't only in the TCK, but also in the spec itself. Some<br>
&gt;&gt;&gt;&gt;&gt; of<br>
&gt;&gt;&gt;&gt;&gt; the examples in section 5.2.4 don't conform to the rules defined in<br>
&gt;&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt; same section (according to the rules, bean Dao&lt;T extends Persistent&gt;<br>
&gt;&gt;&gt;&gt;&gt; shouldn't be eligible for injection into Dao&lt;Order&gt; or Dao&lt;User&gt;). I<br>
&gt;&gt;&gt;&gt;&gt; remember asking about this a year ago ([3]), but I didn't articulate<br>
&gt;&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt; problem properly.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; [1]<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; <a moz-do-not-send="true" href="https://github.com/cdi-spec/cdi/commit/b32243350ace6a0bba337f91a35f5fd0" target="_blank">
https://github.com/cdi-spec/cdi/commit/b32243350ace6a0bba337f91a35f5fd0</a><br>
&gt;&gt;&gt;&gt;&gt; 5c<br>
&gt;&gt;&gt;&gt;&gt; 151f14<br>
&gt;&gt;&gt;&gt;&gt; [2] <a moz-do-not-send="true" href="https://issues.jboss.org/browse/CDITCK-349" target="_blank">
https://issues.jboss.org/browse/CDITCK-349</a><br>
&gt;&gt;&gt;&gt;&gt; [3] <a moz-do-not-send="true" href="http://lists.jboss.org/pipermail/cdi-dev/2012-April/001742.html" target="_blank">
http://lists.jboss.org/pipermail/cdi-dev/2012-April/001742.html</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Marko<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; On 7.7.2013 16:04, Arne Limburg wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; At the OpenWebBeans list we are currently discussing handling of<br>
&gt;&gt;&gt;&gt;&gt;&gt; generics in CDI.<br>
&gt;&gt;&gt;&gt;&gt;&gt; I found a test in the CDI 1.1 TCK, which imho has a bug. The test<br>
&gt;&gt;&gt;&gt;&gt;&gt; is<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; org.jboss.cdi.tck.tests.inheritance.generics.MemberLevelInheritanceTes<br>
&gt;&gt;&gt;&gt;&gt;&gt; t<br>
&gt;&gt;&gt;&gt;&gt;&gt; and the (simplified) deployment scenario is the following:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; public class Baz&lt;T&gt; {<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; public class Qux extends Baz&lt;String&gt; {<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; @Vetoed<br>
&gt;&gt;&gt;&gt;&gt;&gt; public class Bar&lt;T1, T2&gt; {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;@Inject<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;private Baz&lt;T1&gt; baz;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;@Inject<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;private Baz&lt;List&lt;T2&gt;&gt; t2BazList;<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; @RequestScoped<br>
&gt;&gt;&gt;&gt;&gt;&gt; public class Foo extends Bar&lt;String, Qux&gt; {<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; public class Producer {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;@Produces<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;@Amazing<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;public String produceString() {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp; &nbsp;return &quot;ok&quot;;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;}<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;@Produces<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;public String[] produceStringArray() {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp; &nbsp;return new String[0];<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;}<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;@Produces<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;public Baz&lt;Baz&lt;Qux&gt;&gt; produceBazBazQux() {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp; &nbsp;return new Baz();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&nbsp; &nbsp;}<br>
&gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; The class Bar has some more injection points, but that does not<br>
&gt;&gt;&gt;&gt;&gt;&gt; matter.<br>
&gt;&gt;&gt;&gt;&gt;&gt; Due to the TCK this deployment should work, but I don't know how.<br>
&gt;&gt;&gt;&gt;&gt;&gt; Question: Is Baz a Bean (I suppose so) and may it be injected into<br>
&gt;&gt;&gt;&gt;&gt;&gt; Bean Foo, more precisely into the second injection point of class<br>
&gt;&gt;&gt;&gt;&gt;&gt; Bar?<br>
&gt;&gt;&gt;&gt;&gt;&gt; - If yes, it also should be injected into the first injection<br>
&gt;&gt;&gt;&gt;&gt;&gt; point, right? This would lead to an AmbiguousResolutionException<br>
&gt;&gt;&gt;&gt;&gt;&gt; since<br>
&gt;&gt;&gt;&gt;&gt;&gt; Qux may also be injected into the first injection point.<br>
&gt;&gt;&gt;&gt;&gt;&gt; - If no, the deployment should fail with a<br>
&gt;&gt;&gt;&gt;&gt;&gt; UnsatisfiedResolutionException since there is no Bean that can be<br>
&gt;&gt;&gt;&gt;&gt;&gt; injected into that injection point.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Is this a bug in the TCK and if not, how is this supposed to work?<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; Cheers,<br>
&gt;&gt;&gt;&gt;&gt;&gt; Arne<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt;&gt; <a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">
cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt;&gt; <a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">
https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt; <a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">
cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt; <a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">
https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt; <a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">
cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">
https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a></div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</span><br>
<fieldset></fieldset> <br>
<pre>_______________________________________________
cdi-dev mailing list
<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a></pre>
</blockquote>
<br>
</div>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a moz-do-not-send="true" href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
</blockquote>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</span>
</body>
</html>