Take the 2-minute tour ×

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?


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.

share|improve this question
Most of the java code are written in native language... so you might 'c' the method declaration but not the body of it... Also, android for example will obfuscates the sources.. making it harder for you to read even if you decompile it. –  chuthan20 Apr 1 '13 at 1:45
In theory, any nonobfuscated class can be decompiled reasonably well. In practice, all existing decompilers will fail for particularly bizarre and complicated classes. Many don't handle type casting of narrow primatives well either. –  Antimony May 27 '13 at 18:14
add comment

4 Answers

up vote 4 down vote accepted


The answer is No.

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

  • A typical 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.

share|improve this answer
I just mean the bytecode compiled from normal java code. You write some java code, compile it, then decompile it. Can we always get the readable java sources? –  Freewind Apr 1 '13 at 1:59
As an aside, I am currently working on a Java decompiler and am interested in collecting snippets of code which have proven troublesome for existing decompilers. I would be grateful for any specific examples anyone can provide. Note that I am looking for code emitted by well-intentioned compilers (i.e., not obfuscated). This will be an open source decompiler, if that makes any difference. –  Mike Strobel Apr 7 '13 at 19:35
@Freewind - it is hypothetically possible to write a "perfect" decompiler, but in practice no such "perfect" decompiler exists, AFAIK. –  Stephen C Dec 31 '13 at 6:24
add comment

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.

share|improve this answer
ProGuard isn't much of an obfuscator, though it's better than nothing, and most importantly free. But AFAIK, ProGuard doesn't do any flow obfuscation. It only renames everything and strips attributes, which makes the decompiled source harder to understand, but doesn't actually stop decompilers. –  Antimony Apr 1 '13 at 2:10
add comment

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?

share|improve this answer
add comment

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.


share|improve this answer
add comment

Your Answer


