[webbeans-dev] event type with type variable

Pete Muir pmuir at redhat.com
Fri Jul 24 12:46:37 EDT 2009


No, the spec prohibits type variables in event objects and event  
types, it doesn't prohibit type parameters.

This isn't legal

public class Foo{

@Produces <T> Bar make(@Any Event<T> event) {
...

}

and we do need to error at deployment time for such a declaration. Do  
we?

What you show *is* valid.

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 ;-)


On 24 Jul 2009, at 17:28, Dan Allen wrote:

> 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):
>
> public class VoterRegistration<T> { ... }
>
> @Any Event<VoterRegistration<Democrat>> democratRegisteredEvent;
>
> -Dan
>
> -- 
> Dan Allen
> Senior Software Engineer, Red Hat | Author of Seam in Action
> Registered Linux User #231597
>
> http://mojavelinux.com
> http://mojavelinux.com/seaminaction
> http://in.relation.to/Bloggers/Dan
> _______________________________________________
> webbeans-dev mailing list
> webbeans-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/webbeans-dev




More information about the weld-dev mailing list