0

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

lrl
  • 263
  • 4
  • 18
  • 4
    No, the parameter names are only there when the class/jar is compiled in debug mode. Are you trying to get the original parameter name or just iterate and print the values of each variable? – Eric Woodruff Jan 15 '14 at 22:25
  • I was able to implement it with my own class and my IDE added all the methods in my class. – lrl Jan 15 '14 at 22:27
  • So you are using decompiled code? – Hovercraft Full Of Eels Jan 15 '14 at 22:27
  • 6
    Find whoever wrote a method with 43 parameters and subject him to some unspeakable torture until he tells you exactly what they all are for! – rjsang Jan 15 '14 at 22:28
  • i really wish i could – lrl Jan 15 '14 at 22:29
  • 2
    cmon, RE/decompile a c++ program and you know what pain is – Sebastian Hoffmann Jan 15 '14 at 22:29
  • 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 question. Thank you. – lrl Jan 15 '14 at 22:41
  • @rjsang and do it from memory. without looking at the documentation. in reverse order. uphill, both ways. – Joshua Taylor Jan 15 '14 at 22:52
  • I think this question has been answered before, but I'm afraid that unless you want to start diving into AOP, the answer is still that you can't do it. http://stackoverflow.com/questions/4408059/iterating-through-method-parameters – rjsang Jan 17 '14 at 01:29

2 Answers2

2

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

TypeIA
  • 16,916
  • 1
  • 38
  • 52
0

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.

Eric Woodruff
  • 6,380
  • 3
  • 36
  • 33