0

In my recent project, we are in need to modify some business rules, but we don't have source code.

I took latest production deployed jar file and opened it through JD-gui. By using option save All resources i am able to get de compiled java files. Now my questions are:

  1. I see that decompiled java code is having unnecessary line comments on each and every lines. Is there any way to avoid them?

  2. If i make the changes to some file and then compile the code again and send the jar to production, will there be an any hidden challenges?

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
Apt
  • 1
  • 4
  • 3
    Code produced by Java decompliers don't always compile as is. You might end up spending a substantial amount of time fixing compile errors. – assylias Feb 26 '14 at 03:17
  • Consider yourself lucky if it only takes minor modifications to make the code compile and work. – Hot Licks Feb 26 '14 at 03:19
  • Not only does decompiler output not always compile, but it's not necessarily **correct** even if it *does* compile. Be extremely careful redeploying code produced by a decompiler. There are several cases where JD-GUI may produce incorrect code. Other decompilers may be better, but trusting them is still asking for trouble. If you have to go this route, at least compare the output from two or three decent decompilers and make sure the results are consistent. I'd recommend Procyon, CFR, and Krakatau. – Mike Strobel Feb 26 '14 at 16:05

1 Answers1

2

1.That depend which tool you used, most of the case you must clean up by yourself.
2.Some jar file contain MD5 checksum, you must remove or update checksum in order to make your new jar file work.

Kiet Thanh Vo
  • 399
  • 5
  • 16
  • 3) Decompilation will not produce exactly the same code you started with. In the few cases where I've used a decompiler (not the one you're citing), I've seen situations where I had to manually rewrite some of the code before it would compile again, and I'm not sure I'd want to bet the business on a successful round-trip without doing a full code review. – keshlam Feb 26 '14 at 03:20
  • Agree.. there could be some deformations in variable names or something..but as of now my decompiled code is able to compile..without any error...and i found that i need to change one file only..s i am thinking to change that file specifically...compile it and then replace that single file in the original jar... i hope it would work.. – Apt Feb 26 '14 at 05:26