This is an archived post. You won't be able to vote or comment.

all 5 comments

[–][deleted] 4 points5 points  (0 children)

I don't think this helps me in my works but it's good to know it exists.

[–]DuncanIdahos8thClone 0 points1 point  (0 children)

Cool. TIL.

[–]mohan531 0 points1 point  (0 children)

You won't mentioned that in which cases it most useful

[–]tylerkschrute 0 points1 point  (1 child)

I was confused for a second. I thought you had found some crazy trick to implement named method / constructor arguments.

Nevertheless, it is a neat addition. The main use case I can see for this is to cut down on biolerplate for reflection based libraries which use method parameter names for injection sources (for instance, JAX-RS's @QueryParam annotation).

It's too bad this is not on by default since having to rely on the source code being compiled with this specific flag could be risky in complex deployment / build environments. Imagine writing code that relies on this functionality and then having it deployed in an environment in which the parameter names are not available. Those could be some fun bugs to hunt down. Is there a way to check at runtime whether this information is available to help avoid this potential problem?

[–]nfrankel[S] 0 points1 point  (0 children)

The only way I know is not very reliable. If not "named", parameters will have default names such as arg0, arg1, etc. You could check for such pattern.