if (!new Exception().getStackTrace().getSha1sum().startsWith("0000")) alert("hello decompiler")
Your comment about java and turing completeness doesn't make sense unless you want the decompiler to basically output a java implementation of a JVM?
It compiles.
Eventually that disassembled will come along, and then more tricks will be used by the obfuscators...
There is an arms race in whether the resulting output is at all human-comprehensible. The only thing preventing that from terminating with victory for the obfuscaters is that the obfuscators have a finite technical budget with which to obfuscate. Changing identifiers is nearly free, but as you go beyond that and start rewriting the source code itself they start incurring performance penalties and increasing odds that the rewrite will fail as they get more aggressive.
The interesting part to me is that it seems that Java would be perfectly capable of differentiating between methods by return type if the compiler was tweaked slightly. Is there a reason why this isn't a formal language feature?
Edit: here's the edge case though. You can call a function and use the return value directly as a parameter: foo(bar()). It's possible to have two foo that take both possible bar return types, at which point the compiler is stuck.
It could require a cast in this instance, however. The more I think about this the more I wonder why this isn't possible.
That's no more an edge case than the cases where you throw away the return value or you're binding to an ambiguous type e.g. `A getFoo()`, `B getFoo()`, `Object foo = getFoo()`.
> The more I think about this the more I wonder why this isn't possible.
The Java spec does not say, for C++ Stroustrup states it's
> to keep resolution for an individual operator or function call context-independent.
the Java reason is likely also some sort of Principle of Least Surprise claim.
Edit: Based on the responses below, I guess the point is that the disassembler can't generate Java code that will "naively" (wrong word, but I can't think of a better one) generate the same output. Notable (I assume) in that name munging would be problematic outside the current compilation unit.