Java 6 Decompiler Joshua Cranmer
Steps of Decompilation Parse Java class file Recreate signatures Convert bytecode to Java executable code Verify bytecode Perform trivial conversion Reconstruct control structures Scope & Type Variables Simplify code
Last Time Class parsing: Signature recreation: All required information recovered Java 5 attributes recovered: signature, varargs, enums Debug attributes recovered: variable names Signature recreation: Valid for any method, field, class Enums, annotations partially destroyed No inner classes
Now Class parsing: Signature recreation: Bytecode conversion: Annotations fully recoverable Signature recreation: All information relating to annotations updated Bytecode conversion: Some simple types convertible Some scoping and typing of variables Minimal verification
Bytecode conversion Successive iterations of transforms Many can be condensed at this point Two main runs: StackAnalyzer + assorted StackAnalyzer verifies bytecode, performs SSA analysis, asserts certain invariants Assorted transforms provides trivial decompilation Trivial: aload_0; invokesuper <init>()V; return becomes super(); return
Variable Scoping and Typing MOST DIFFICULT PART Creation of SSA form: Each variable is only assigned to once Maximal variable assumption SSA unification: ongoing research Type is easy iff variables are not over-scoped
Future Cleanup of transformation sequences Start converting control structures Handle variables better