implementing the TypeVariable interface

T

transkawa

can anyone demonstrate to me how to implement the TypeVariable<D extends
GenericDeclaration> interface of the java.lang.reflect package?
would really be helpful for me to see an algorithm that implements
getBounds() and getGenericDeclaration(). am in the clouds from reading the
language spec.
xnt
david
 
M

markspace

transkawa said:
can anyone demonstrate to me how to implement the TypeVariable<D extends
GenericDeclaration> interface of the java.lang.reflect package?
would really be helpful for me to see an algorithm that implements
getBounds() and getGenericDeclaration(). am in the clouds from reading the
language spec.


I don't think one would implement a TypeVariable. One gets an
implementation from an instance of java.lang.Class.

<http://java.sun.com/docs/books/tutorial/reflect/>

Short example:

import static java.lang.System.out;

.....

/** method to list type parameters */
void listTypes( Object o ) {
Class c = o.getClass();
TypeVariable[] tv = c.getTypeParameters();
if (tv.length != 0) {
out.format(" ");
for (TypeVariable t : tv)
out.format("%s ", t.getName());
out.format("%n%n");
} else {
out.format(" -- No Type Parameters --%n%n");
}
}

I didn't test that, but most of it I got from that link I gave you. It
should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top