Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [jdt-apt-dev] Fwd: About TypeDeclaration.getActualTypeArguments()

Thanks, Compl. I saw you filed a bugzilla bug against the APT project
for this -- we're working on a fix now.

Cheers,
Jess

-----Original Message-----
From: jdt-apt-dev-bounces@xxxxxxxxxxx
[mailto:jdt-apt-dev-bounces@xxxxxxxxxxx] On Behalf Of Compl Yue Still
Sent: Saturday, December 10, 2005 4:55 AM
To: jdt-apt-dev@xxxxxxxxxxx
Subject: [jdt-apt-dev] Fwd: About
TypeDeclaration.getActualTypeArguments()

I have made sure that my code runs well under SUN apt, while JDT apt
keep throwing
ClassCastException described here, this should be a bug of Eclipse JDT
apt.

I suppose you need to write dedicated implementations for DeclaredType
and all its subinterfaces,
including ClassType,InterfaceType and etc. Now they are implemented by
their corrsponding
declaration implementation class, this seems incorrect.

--- Compl Yue Still <complystill@xxxxxxxxxxxx> wrote:

> Date: Sat, 10 Dec 2005 00:55:43 -0800 (PST)
> From: Compl Yue Still <complystill@xxxxxxxxxxxx>
> Subject: Fwd: About TypeDeclaration.getActualTypeArguments()
> To: jdt-apt-dev@xxxxxxxxxxx
> 
> In addition, I did search up the type hierarchy for the judgement, in
a simular example, I was
> testing a field of type Set<Integer> vs Collection<Number> and been
expecting it return true. I
> started with the DeclaredType for Set<Integer> and called
getSuperinterfaces() on it to get the
> DeclaredType for Collection<Integer>, maybe the getSuperinterfaces()
call removed the type
> parameter <Integer> and just returned the erased type Collection ??
> 
> --- Compl Yue Still <complystill@xxxxxxxxxxxx> wrote:
> 
> > Date: Sat, 10 Dec 2005 00:38:03 -0800 (PST)
> > From: Compl Yue Still <complystill@xxxxxxxxxxxx>
> > Subject: About TypeDeclaration.getActualTypeArguments()
> > To: jdt-apt-dev@xxxxxxxxxxx
> > 
> > Hello buddies,
> > 
> >    I met some problem with TypeDeclaration.getActualTypeArguments(),
I don't know if my
> > understand
> > is correct that this invocation should return the concrete types
substituting the formal type
> > parameters as possible.
> >    The last straw was that I called Types.isAssignable(TypeMirror,
TypeMirror) with a type
> > parameter from the generic type of a field declaration, and ended up
with a
> >
ClassCastException:org.eclipse.jdt.apt.core.internal.declaration.TypePar
ameterDeclarationImpl
> > 
> >    After some dig, I found the implementation here:
> > 
> >     public Collection<TypeMirror> getActualTypeArguments()
> >     {
> >         final ITypeBinding type = getTypeBinding();
> >         final ITypeBinding[] typeArgs = type.getTypeArguments();
> >         if( typeArgs == null || typeArgs.length == 0 )
> >     		return Collections.emptyList();
> > 
> >         final Collection<TypeMirror> result = new
ArrayList<TypeMirror>(typeArgs.length);
> >         for( ITypeBinding arg : typeArgs ){
> >             final TypeMirror mirror = Factory.createTypeMirror(arg,
_env);
> >             if(arg == null)
> >                 result.add(Factory.createErrorClassType(arg));
> >             else
> >                 result.add(mirror);
> >         }
> > 
> >         return result;
> >     }
> > 
> >    Is this CORRECT? If it is, please any buddy tell me how to test
that whether the type
> > parameter
> > of a field declaration is sub class of a specific one? Say, when
processing annotations, how
> can
> > I
> > see whether a field is of type Set<? extends Collection>, but not a
Set<String> ? In this case
> a
> > field of type Set<List> should return true while type Set<String>
should return false.
> > 
> >    Thanks in advance to any hint!
> > 
> > Compl Yue Still
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around 
> > http://mail.yahoo.com 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
jdt-apt-dev mailing list
jdt-apt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jdt-apt-dev


Back to the top