Type argTypes = method. GetParamterTypes() I believe you are missing an "e" in your method call, should be getParameterTypes().
Typo correction. – java_enthu Jul 8 at 11:57 you should write this in a comment, as this is not really an answer to the question – x0r Jul 8 at 12:09 @x0r: He can't; he doesn't have enough reputation yet. – Donal Fellows Jul 8 at 12:10 @Donal Fellows: right thanks, forgot that you need rep to do that – x0r Jul 8 at 12:13.
Because as stated in method. GetGenericParameterTypes() JavaDoc it: returns an array of Type objects that represent the formal parameter types ... If a formal parameter type is a parameterized type, the Type object returned for it must accurately reflect the actual type parameters used in the source code. Thus if your method declaration looks like: public void myMethod(String string, List list) { ... } argTypes0 will contain instance of Class (i.e.
Class), but argTypes1 will contain instance of java.lang.reflect. ParameterizedType. You can get information about actual type arguments of ParameterizedType using getActualTypeArguments() method.
Example for case I described above: Type listTypeArgs = ((ParameterizedType) argTypes1). GetActualTypeArguments() // listTypeArgs. Length == 1 as List have one type argument // listTypeArgs0 now contains instance of Class.
– java_enthu Jul 8 at 12:28 Please check my updated answer. I could help you more if I understand better what you are trying to achieve. Could you please post more code (preferably with some real usage example)?
– Idolon Jul 8 at 13:42.
Since your method argument is a parameterized collection type, getGenericParameterTypes returns a ParameterizedType, not a Type. To get the actual type, you need to first check whether each element of argTypes is an instance of ParameterizedType, and if it is call ParameterizedType. GetActualTypeArguments().
Having said that, I can't tell what your code is trying to do. Your result object is still a List, so you are still going to have to cast the elements to their correct type when you get them from the list. Casting the elements before storing them in the list doesn't accomplish anything.
List acutalValues = // List of actual values from method input. // Resultant list of arguments which will holds casted values. List arguments = new ArrayList(argTypes.
For (int I = 0; I requiredClassTYpe = (Class) argTypesi; // argTypes1 =java.util. // cast the actual value to the required type. ClassCastException: Cannot cast sun.reflect.generics.
ParameterizedTypeImpl (id=77) to java.lang. Type argTypes = method.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.