hey everyone! I am using introspection and would like to get a method using
The method I want to get takes a string array as the parameter type. But I am not sure how to get a Class instance that represents an array so I can use the method call above. Is it even possible? In the past, I have just used getMethods() and found the method by comparing the class names of the parameter types of each method to "[Ljava.lang.string;". But this seems like a huge kludge to me and takes away from the simplicity of the code. Any ideas?
Yup. There are also class literals for primitive types: int.class boolean.class float.class The only use I know for these is just what you're doing - specifying parameter/return types for reflection. These are not the same as Integer.class Boolean.class Float.class (Which can also be used to specify parameter/return types - but different types.) Even weirder, there's: void.class As far as I can tell, the only time this is used is to talk about the return type of a method with reflection. (For parameter lists there's no need - instead of a void parameter, you'd just use a zero-length Class array.) [ August 20, 2002: Message edited by: Jim Yingst ]