lrl
lrl

Reputation: 263

Java variable names out of strings

Have a problem with undocumented libraries, where I am trying to replace some classes in the .jar without any source code provided. One class is implemented from an existing one (no java file for it) so i have all the methods and method signatures but the no way to make any sens out of parameters because they are all named arg0, arg1..., because there are a lot of methods and some contain up to 43 parameters trying to loop through the parameters in order to see what is coming in. Is there any way to use String and dynamically get to that variable?

edit: ---more info--- Everything is compiled in the jar file, which I was able to repackage without one class that I want to change. So, the class that I want to change extended another class which is compiled. So, when extended the compiled class my IDE auto-generated all the methods and their signatures whre the parameters are named sequentially and I would like to place a for-loop in every function to see what is coming in instead of go one-by-one and print it to the console. I think I was a little vague in the original question.

Thank you

Upvotes: 0

Views: 100

Answers (2)

Eric Woodruff
Eric Woodruff

Reputation: 6410

You can't get access to the parameter names unless the class was compiled in debug mode. But if you just want to iterate and print the values of each parameter passed in, mockito might be able to help you there if you mock the method. Or you can just step with a graphical debugger.

Upvotes: 0

TypeIA
TypeIA

Reputation: 17250

No, if those symbols have been removed from the compiled class file, you cannot recover them.

Upvotes: 2

Related Questions