getting parameter names of amethod
In reflection API it is possible to find out type of parameters of a method, is there any way to discover parameter names to?
I think parameter names are just stored in classes when they are compiled with debug information on, so I want to get them then. And I know there must be a way, cause some IDEs likeIDEA do that.
By the way is there any way to mark a class that it only compiles with debug info on? (or always have the parameter names?)
> In reflection API it is possible to find out type of
> parameters of a method, is there any way to discover
> parameter names to?
No
> I think parameter names are just stored in classes
> when they are compiled with debug information on,
No
> And I know there must be a
> way, cause some IDEs like IDEA do that.
They get them from the source or the Javadoc.
> By the way is there any way to mark a class that it
> only compiles with debug info on? (or always have the
> parameter names?)
No
But there must be a way, just look at http://static.springframework.org/spring/docs/2.0-rc2/reference/aop.html#d0e7328 .
Consider @AfterReturning's returning attribute in 6.2.4.2. After returning advice and @AfterThrowing's throwing attribute in 6.2.4.3. After throwing advice! they all work with pure Java 5 (not only with AspectJ),
So I believe there must be way. I think I must dig the Spring's codes ;) Anybody can help?
> I think parameter names are just stored in classes when they are compiled with debug information on
Sort of. You should be able to use the LocalVariableTable to match them up. However, reflection doesn't support it. You'll have to parse the class file with something like ASM or BCEL.