I don't think you can get the instance type information from within the class as it is erased by the compiler.
-----Original Message----- From: Yang ZHONG [mailto:[EMAIL PROTECTED] Sent: 28 June 2006 18:22 To: tuscany-dev@ws.apache.org Subject: Re: Question on java generics Given Collection<String> strings = ...; Collection<Integer> integers = ...; According to Java language spec, this is true: strings.getClass() == integers.getClass() After all, Java doesn't generate .class files for EACH parametization/instantiation like C++. It seems impossible to get the parameter type from strings.getClass(). HOWEVER, what I have been discussing and what I guessed Raymond originally wanted is INSTANCE type. For DECLARATION type, it's different, as Meeraj ponited out, you can get field DECLARATION type. As for class itself, I guess parametized info may be available as super type DECLARATION. It'll be very interesting if template/generic INSTANTIATION info can be found given only one .class file each type. On 6/28/06, Jeremy Boynes <[EMAIL PROTECTED]> wrote: > > On 6/28/06, Meeraj Kunnumpurath <[EMAIL PROTECTED]> wrote: > > Raymond, > > > > You can get the type of T if you have a parameterized field of a > > generic type. Some thing like this, > > > > <snip/> > > I think you can also get the parameterized type information from Class > itself. Jim was doing some introspection like this to help with > registration callbacks - have a look in BuilderRegistryImpl#register. > > -- > Jeremy > -- Yang ZHONG This message has been checked for all email viruses by MessageLabs. ***************************************************** You can find us at www.voca.com ***************************************************** This communication is confidential and intended for the exclusive use of the addressee only. You should not disclose its contents to any other person. If you are not the intended recipient please notify the sender named above immediately. Registered in England, No 1023742, Registered Office: Voca Limited Drake House, Three Rivers Court, Homestead Road, Rickmansworth, Hertfordshire, WD3 1FX This message has been checked for all email viruses by MessageLabs. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]