In Java6, imagine I have the following method signature:
public void makeSandwich(Bread slice1, Bread slice2, List<Filling> fillings, boolean mustard)
Parameter names are available if you have told the compiler to include them (compile with debug information). Spring has
ParameterNameDiscoverer which can help you obtain the names. The default implementation uses asm
ClassReader to do so.
javac you should include the
-g argument to include debug information. With eclipse I think it is there by default.
Some frameworks use this. For example spring-mvc has
@RequestParam which defaults to the param name, if resolvable. It also supports explicit naming -
@RequestParam("foo") in case no debug information is provided.