Oki, a few thoughts about ClassUtil#getClazz:

this function is mainly used to get the list of 'boundary types' e.g. when 
parsing member methods of an annotated class. In the case mentioned below, I 
get a TypeVariable, but I do not get the actually used Type from the class. 
Reason is that in the caller down below a getGenericParameterType() is now 
called instead of getParameterType() which has been used previously. But sadly 
with only the generic TypeVariable, there is imho now way to detect the 
actually compiled type from the b-code.

So if we would had the chance to detect e.g. a single upper bound which is not 
Object, should we use it?
((TypeVariable)type).getBounds()[0]; ?


my current code hack:

    public static Class<?> getClazz(Type type)
    {
        Class<?> raw = null;
        
        if(type instanceof ParameterizedType)
  ...
        else if(type instanceof GenericArrayType)
  ...
        else if (type instanceof TypeVariable) {
            return Object.class; // maximum upper boundary, or should we return 
null?
        }
        
        return raw;
    }


LieGrue,
strub



----- Original Message ----
> From: Gurkan Erdogdu <[email protected]>
> To: [email protected]
> Sent: Tuesday, August 4, 2009 1:50:49 PM
> Subject: Re: generic classes allowed as bean type?
> 
> Awesome! talk later than.
> 
> thanks
> Gurkan
> 
> 
> 2009/8/4, Mark Struberg :
> >
> > Hi Gurkan!
> >
> > First, thanks for your answer!
> > 2nd, enjoy your holidays :)
> >
> > I already found section 5.3.3 which answered my question.
> > In general this usecase is a valid one, and is also covered in the TCK.
> >
> > Locally, I did a really dirty hack by returning Object.class as upper
> > boundary from the type erasure for now (in ClassUtil#getClazz).
> > I didn't check this in, but now I'm at least able to continue with the TCK
> > hacking.
> >
> > LieGrue,
> > strub
> >
> >
> >
> > ----- Original Message ----
> >> From: Gurkan Erdogdu 
> >> To: [email protected]
> >> Sent: Tuesday, August 4, 2009 1:32:07 PM
> >> Subject: Re: generic classes allowed as bean type?
> >>
> >> more on this, type variable is not valid bean injection type. you can
> >> not resolve any bean to injection point with type variables.
> >>
> >> hope this helps;
> >>
> >> 2009/8/2, Mark Struberg :
> >> >
> >> > Hi!
> >> >
> >> > While trying to run the TCK suite, I came across a problem while parsing
> >> > the
> >> > class
> >> >
> >> > public class MockCreationalContextimplements CreationalContext;
> >> >
> >> > with WebBeansLifecycle#applicationStarted
> >> >
> >> > The problem is the generic type T (a javax.reflect.generic.TypeVariable)
> >> > which doesn't resolve to a 'real' class and since crashes OWB.
> >> >
> >> > How do we solve this? From reading the spec I cannot even say if this is
> >> > a
> >> > valid bean type at all.
> >> > On the on hand it is not listed in the taxative list of valid bean
> >> > types.
> >> > On the other hand, an example with an _applied_ type is shown in the
> >> > spec
> >> > (class BookShop implements Shop)
> >> >
> >> > Gurkan, are you online tomorrow evening?
> >> >
> >> > LieGrue,
> >> > strub
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >> --
> >> Gurkan Erdogdu
> >> http://gurkanerdogdu.blogspot.com
> >
> >
> >
> >
> >
> 
> 
> -- 
> Gurkan Erdogdu
> http://gurkanerdogdu.blogspot.com



      

Reply via email to