RE: Question on java generics

2006-06-28 Thread Meeraj Kunnumpurath
-Original Message- From: Yang ZHONG [mailto:[EMAIL PROTECTED] Sent: 28 June 2006 01:19 To: tuscany-dev@ws.apache.org Subject: Re: Question on java generics 1) No. T is erasable. 2) If myClass is a class or generic type, you should be able to new TestmyClass. On the other hand, if myClass

Re: Question on java generics

2006-06-28 Thread Jeremy Boynes
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

Re: Question on java generics

2006-06-28 Thread Yang ZHONG
Given CollectionString strings = ...; CollectionInteger 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

RE: Question on java generics

2006-06-28 Thread Meeraj Kunnumpurath
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

Question on java generics

2006-06-27 Thread Raymond Feng
Generics gurus, Assuming I have the following class: public class TestT { ... } 1) Is there a way to get the Class object for T in class Test? I know T.class is illegal. 2) Can I create the an instance of Test using a Class object myClass. I know new TestmyClass is not valid. Thanks, Raymond

Re: Question on java generics

2006-06-27 Thread Yang ZHONG
1) No. T is erasable. 2) If myClass is a class or generic type, you should be able to new TestmyClass. On the other hand, if myClass is a pointer/variable, no you can't new TestmyClass On 6/27/06, Raymond Feng [EMAIL PROTECTED] wrote: Generics gurus, Assuming I have the following class: