Reputation: 117
I am using paranamer.jar to get the parameter names of a method. But it does not get any parameter names.
Class c = Class.forName("com.soa1.MyClass");
Class[] argTypes = { java.lang.String.class };
Method method=ABC.class.getMethod("getData",argTypes);
Paranamer paranamer = new CachingParanamer();
String[] parameterNames = paranamer.lookupParameterNames(method,false);
Upvotes: 0
Views: 766
Reputation: 216
keep the debug information when compiling
if you are compiling with eclipse so check the option keep debug information in project-properties-java compiler
if you are compiling with javac add -g option
and in your code use Paranamer paranamer = new AdaptiveParanamer();
Upvotes: 0
Reputation: 61
Use this:
Paranamer paranamer = new AdaptiveParanamer();
Instead this:
Paranamer paranamer = new CachingParanamer();
If are not working yet, tell me, cause I have trouble with paranamer too - after help of a brazilian friend I've learned how it works. See ya!
Upvotes: 0
Reputation: 223083
Did the parameter names come from somewhere? According to ParaNamer's documentation, it uses several ways to obtain parameter names:
__PARANAMER_DATA
field. Obviously, this only works if your class has such a field..class
file. Obviously, this only works if your class was compiled with debugging information.@Named
annotation. Obviously, this only works if your method parameters contain such an annotation.If none of these apply to your class, then sorry, parameter names will not be available.
Upvotes: 3