2

I have seen a lot of videos where everyone is decompiling the jar files so easily. but I learnt that we cannot decompile any compiled file so easily. I have a little bit of experience in Gidhra. I have analyzed some C compiled binaries. the C compiled binaries aren't that easy to decompile, I have seen it myself. but how does java decompilation works? tools just extract all source code written in it. you can take this video as an example, Youtube IPPSEC Please tell me the difference between C and Java compiled files decompilation.

2
  • 1
    Have you tried searching online for "Why is Java easier to decompile than C"?
    – Antimony
    Commented Aug 13, 2020 at 5:18
  • 1
    To add/showcase this phenomenon (ease of decompilation), here is a paper (2019 - August) containing tables that showcase the accuracy of current Java decompilers: arxiv.org/pdf/1908.06895.pdf
    – Col-E
    Commented Aug 18, 2020 at 17:32

1 Answer 1

4

In short, the difference is in the format into which Java and native code are compiled and executed. Compilation into native code formats eliminates from resulting executable a lot of information that Java code keeps by design, including, but not limited to the following list:

  • Class names
  • Method names
  • Properties names and types
  • Methods borders
  • Exact exception definitions
  • Class structure
  • So called bytecode code of the methods in language which is very easy to understand and decompile because it is reference-based language and contains exact signatures of other called methods by design

The more we know about the code, the easier it is for us to understand (and decompile) it.

Java code is executed in Java Virtual Machine (JVM). Native code is executed on the processor directly.

JVM is executing .jar files. .jar files are zip archives that contain .class files with definitions of classes. This format is defined here and we can find in the referenced document everything that class file contains. Most of information we know about java bytecode is lost during the native code compilation.

If you want to understand a bit more about java classes internals I'd suggest you to write some simple java class, compile it and then disassemble it with javap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.