0

I could parse .java files in their physical location on disc, but is it possible to "decompile" java class to code-String during runtime?

What I am trying to achieve - I am writing something like test-tool and I need to get the code itself - so the syntaxis of function need to be tested

curiousity
  • 4,703
  • 8
  • 39
  • 59
  • Sure, iterate on the file, read it line by line. – Maroun Oct 22 '14 at 10:55
  • Can you explain what do you want to achieve? – Mariusz Nosiński Oct 22 '14 at 10:57
  • If you just want to decompile a .class file , you can check this [How do I “decompile” Java class files? ] (http://stackoverflow.com/questions/272535/how-do-i-decompile-java-class-files). This is not at the runtime though. – Scrooge McD Oct 22 '14 at 11:13
  • You shouldn't really need it. If you're writing a test tool, you can probably ask the user to supply the source code of the code to the tested. Then you can link the compiled code to the source via line number info, which can be extracted from a class file. (Provided that it was compiled with debug information enabled.) – biziclop Oct 22 '14 at 11:48

0 Answers0