reflection cant get parameterized method signature?

my sample:

interface Root<T>{

public void prt(T t );

}

interface A extends Root<String>{

}

public class Reflecttest {

public static void main(String[] args){

Class cl=A.class;

for (Method m:cl.getMethods()){

m.getParameterTypes();

....................

//som reflection like above, but i cant get signature like public void prt(String str); but public void prt(Object o);

//how can i get the parameterized method signature

}

}

[539 byte] By [albert.chiaoa] at [2007-11-26 20:50:56]
# 1
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Method.html#getGenericParameterTypes()
ejpa at 2007-7-10 2:15:47 > top of Java-index,Core,Core APIs...
# 2
but how? i mean how to know that the method in A extends from Root which generic type has been parameterized to String?
albert.chiaoa at 2007-7-10 2:15:47 > top of Java-index,Core,Core APIs...
# 3
That information doesn't exist at runtime. It is all erased to Object by the compiler. That's what Generics does - safe type erasure
ejpa at 2007-7-10 2:15:47 > top of Java-index,Core,Core APIs...
# 4

> That information doesn't exist at runtime. It is all

> erased to Object by the compiler. That's what

> Generics does - safe type erasure

further, you don't need to know, since by using reflection you're basically bypassing compile-time type safety altogether. reflection and generics have totally different intents, and don't mix well together

georgemca at 2007-7-10 2:15:47 > top of Java-index,Core,Core APIs...