Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to tell compiler to keep variable names around via annotations?

It is very annoying to have the whole app add an @Param() annotation with the variable name for each variable name. It is also frustrating when you change the variable name and have to change the name inside @Param

Is there any good way to annotate a method so the compiler knows to keep the meta information of variable names around?

I notice in eclipse compiler, I am getting arg0, arg1 back and this is in debug mode as I step through my code. How to set it so the actual variable names are coming through?

Lastly, I took a peak at how Play 1.3 was handling this and it was using javassist and bytecode stuff (which I prefer to keep out of the app) but was still unsure how that is working. Does anyone know how I could do it that way(more for learning than anything)

thanks, Dean

like image 592
Dean Hiller Avatar asked Oct 19 '22 07:10

Dean Hiller


1 Answers

In my understanding you try to preserve the variable names in the fingerprint of a method. If it is right there is a solution for you:

Shortly: add -g:wars to the compiling command line or in Eclipse check out the following setting: Eclipse -> project properties -> Java compiler -> Add variable attributes to generated class files. Source

like image 70
Hash Avatar answered Oct 21 '22 04:10

Hash