[webbeans-dev] event type with type variable
David Allen
drallendc at gmail.com
Fri Jul 24 13:00:42 EDT 2009
On Fri, 2009-07-24 at 17:46 +0100, Pete Muir wrote:
> 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?
There already is a test exactly like this:
org.jboss.jsr299.tck.tests.event.broken.inject.withTypeVariable.EventInjectionWithUndefinedTypeVariableTest, but apparently the RI does not detect the error. The test is also not currently assigned to any assertion, but the spec clearly states that this is not allowed; however, it states that a IllegalArgumentException is to be thrown, both runtime and not (Section 10.3.1).
>
> 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
>
> _______________________________________________
> 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