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

Reply via email to