I'm going to tread carefully when arguing this point because I am far from a master at generics. Unfortunately, it seems that the non-normative section of the generics documentation is not consistent with the generics API. For instance, in the documentation, a type parameter is described as a special kind of type variable. But in the generics API, they are two separate things (ParameterizedType and TypeVariable). But I may be mistaken.<br>
<br>With that said, the example I gave fails in Web Beans. Let me give a full example:<br><br>public class Artist<T> { ... }<br><br>public class Solo { ... }<br><br>public class TuneSelect {<br> @Any Event<Artist<Solo>> soloArtistEvent;<br>
<br> public void soloArtistPlaying(Artist<Solo> artist)<br> {<br> soloArtistEvent.fire(artist);<br> }<br>}<br><br>Here's the exception Web Beans spits out.<br><br>java.lang.IllegalArgumentException: Event type org.jboss.jsr299.tck.tests.event.eventTypes.Artist is not allowed because it is a generic<br>
at org.jboss.webbeans.BeanManagerImpl.fireEvent(BeanManagerImpl.java:798)<br> at org.jboss.webbeans.event.EventImpl.fire(EventImpl.java:76)<br><br>=> same result for soloArtistEvent.fire(new Artist<Solo>())<br>
<br>If you believe that should be valid, then I will simply mark it as ri-broken.<br><br>I see what you are saying though in that what is not allowed is a type which is tied to the method parameters, hence acting as a type variable.<br>
<br>-Dan<br><br><div class="gmail_quote">On Fri, Jul 24, 2009 at 12:46 PM, Pete Muir <span dir="ltr"><<a href="mailto:pmuir@redhat.com">pmuir@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
No, the spec prohibits type variables in event objects and event types, it doesn't prohibit type parameters.<br>
<br>
This isn't legal<br>
<br>
public class Foo{<br>
<br>
@Produces <T> Bar make(@Any Event<T> event) {<br>
...<br>
<br>
}<br>
<br>
and we do need to error at deployment time for such a declaration. Do we?<br>
<br>
What you show *is* valid.<br>
<br>
It's also not valid to actually pass an event object with a type variable, but it's extremely hard to actually find code that will compile and pass the above deployment test, but still do this and do this so I can't find an example right now ;-)<div>
<div></div><div class="h5"><br>
<br>
<br>
On 24 Jul 2009, at 17:28, Dan Allen wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
In several places, the specification reiterates that an event type may not contain a type variable. However, it appears that this restriction is only enforced at runtime when the event object is passed to either Event#fire() or BeanManager#fireEvent() method. I would suggest that an validation check be added so that the container detects an illegal Event definition at deployment type. Here's an example of an illegal definition (from my understanding):<br>
<br>
public class VoterRegistration<T> { ... }<br>
<br>
@Any Event<VoterRegistration<Democrat>> democratRegisteredEvent;<br>
<br>
-Dan<br>
<br>
-- <br>
Dan Allen<br>
Senior Software Engineer, Red Hat | Author of Seam in Action<br>
Registered Linux User #231597<br>
<br>
<a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br>
<a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br>
<a href="http://in.relation.to/Bloggers/Dan" target="_blank">http://in.relation.to/Bloggers/Dan</a><br></div></div><div class="im">
_______________________________________________<br>
webbeans-dev mailing list<br>
<a href="mailto:webbeans-dev@lists.jboss.org" target="_blank">webbeans-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/webbeans-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/webbeans-dev</a><br>
</div></blockquote>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>Dan Allen<br>Senior Software Engineer, Red Hat | Author of Seam in Action<br>Registered Linux User #231597<br><br><a href="http://mojavelinux.com">http://mojavelinux.com</a><br>
<a href="http://mojavelinux.com/seaminaction">http://mojavelinux.com/seaminaction</a><br><a href="http://in.relation.to/Bloggers/Dan">http://in.relation.to/Bloggers/Dan</a><br>