File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to obtain parameter of parametrized class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to obtain parameter of parametrized class?" Watch "How to obtain parameter of parametrized class?" New topic
Author

How to obtain parameter of parametrized class?

Tymur Porkuyan
Greenhorn

Joined: Dec 12, 2005
Posts: 7
Is it possible to obtain a reference to a class which is a parameter of a generic class? I tried this, but it didn't work:



Is there any other way or it's impossible?
[ February 07, 2006: Message edited by: Timur Porkuyan ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

If you have an instance of the parameter type, then you can call getClass() on that instance.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by marc weber:
If you have an instance of the parameter type, then you can call getClass() on that instance.


That's not exactly the same, as the instance could also be of a subclass.

And to answer the original question: no, this is not possible in Java.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Tymur Porkuyan
Greenhorn

Joined: Dec 12, 2005
Posts: 7
Thanks.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Ilja Preuss:
... That's not exactly the same, as the instance could also be of a subclass...

Good point.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to obtain parameter of parametrized class?
 
Similar Threads
Problem about the PortableRemoteObject method
how to setup parameters dynamically in iBATIS?
iBatis | Function Call as a Paramter to Procedure Call?
iBATIS multiple parameterClass
IBATIS - multiple parameter