Question

I see some java decompilers can decompile bytecode to readable java sources, I wonder if all the bytecode which comes from java (not other JVM language) can be decompiled to java sources again?


Update

Sorry, let me make the question more clear.

Just talk about the normal Java code on JVM (no Android, no bytecode enhance, no AOP, no obfuscation), and I actually hope the bytecode can be decompiled. But I don't know if there are forms of java code which compiled into bytecode, will never be able to be decompiled to readable java sources.

Was it helpful?

Solution

I wonder if all the bytecode which comes from java (not other JVM language) can be decompiled to java sources again?

The answer is No.

Decompilers aren't guaranteed to work for all Java bytecodes:

  • A good obfuscator will deliberately rearrange the bytecodes in such a way that the common decompilers won't produce readable source code ... and probably won't produce valid source code.

  • Many decompilers out there have problems dealing with newer Java constructs.

  • Many decompilers have problems with bytecodes compiled from "complicated" source code.

  • Even if they generate compilable code, there is no guarantee that the code will be correct.

The bottom line is that a decompiler is only as good as the intelligence and diligence of its author can make it. I've never heard of a perfect one.

OTHER TIPS

Java byctecode can be decompiled back to java source code. The decompiled source will generally not look the exact same, but will have the same functionality. If you're concerned that someone might decompile your source, you can use obfuscators (like ProGuard) to help.

Yes this is (in general) possible (there exists multiple tools for this). See: How do I "decompile" Java class files?

However you can try to secure your files from this, see: How to lock compiled Java classes to prevent decompilation?

I had the opportunity to decompile java multiple codes, and always managed with the tools available, to think that the byte code is generated by a compiler this process only needs to be reversed to get the original code. I know of a way to avoid this.

I used this tool.

java.decompiler.free.fr

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top