[webbeans-dev] TypeVariabe Event Type

Pete Muir pmuir at redhat.com
Wed Aug 26 15:42:33 EDT 2009


On 26 Aug 2009, at 20:33, Gurkan Erdogdu wrote:

> I also implemented ProcessAnnotatedType like
>
> public class ProcessAnnotatedTypeImpl<X> impements  
> ProcessAnnotatedType<X>{}
>
> then firing event like this
> ProcessAnnotatedType<X> event = new ProcessAnnotatedTypeImpl<X>();
> or
> ProcessAnnotatedType<?> event = new ProcessAnnotatedType();

Thats not quite what I wrote, note the includsion of a pair of braces,  
causing an anonymous inner class to be created () {}

> Then in BeanManagerImpl.fireEvent(Object event, ....)
> event.getClass.getTypeParameters always returns TypeVariables.

I believe this method all return's type variables.

>
> >>>You must create a sub class, this then allows Java to resolve the  
> type variables
> What do you mean by saying "allows Java to resolve the type  
> variables"?

The type variables of a parameterized type can sometimes be resolved  
to an actual type, sometimes they can't. This is defined by the Java  
Language Spec (where it discusses type inference).

They can in the case of a subclass of a generic type, they can't for  
the class itself.

>
> --Gurkan
>
> From: Pete Muir <pmuir at redhat.com>
> To: Gurkan Erdogdu <gurkanerdogdu at yahoo.com>
> Cc: webbeans-dev at lists.jboss.org
> Sent: Wednesday, August 26, 2009 10:21:54 PM
> Subject: Re: [webbeans-dev] TypeVariabe Event Type
>
> Yes, you can't fire an event of type Foo<T>. You must create a sub  
> class, this then allows Java to resolve the type variables. In the  
> RI we do
>
> new ProcessAnnotatedTypeImpm<T>() {};
>
> to achieve this.
>
> On 26 Aug 2009, at 20:15, Gurkan Erdogdu wrote:
>
> > Hi;
> >
> > In method, public void fireEvent(Object event, Annotation...  
> qualifiers) in BeanManager; spec specifies that runtime event type  
> can not be TypeVariable. But when I look at portable events, all of  
> them contain type variable.
> >
> > For Example;
> >
> > ProcessAnnotatedType<X>
> >
> > When fires this event, event.getClass.getTypeVariables always  
> contain TypeVariable.
> >
> > Is this true?
> >
> > Thanks;
> >
> > --Gurkan
> >
> >
> > _______________________________________________
> > 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