Decompiling Java Bytecode: Problems, Traps and Pitfalls

  • Jerome Miecznikowski
  • Laurie Hendren
Conference paper

DOI: 10.1007/3-540-45937-5_10

Part of the Lecture Notes in Computer Science book series (LNCS, volume 2304)
Cite this paper as:
Miecznikowski J., Hendren L. (2002) Decompiling Java Bytecode: Problems, Traps and Pitfalls. In: Horspool R.N. (eds) Compiler Construction. CC 2002. Lecture Notes in Computer Science, vol 2304. Springer, Berlin, Heidelberg

Abstract

Java virtual machines execute Java bytecode instructions. Since this bytecode is a higher level representation than traditional object code, it is possible to decompile it back to Java source. Many such decompilers have been developed and the conventional wisdom is that decompiling Java bytecode is relatively simple. This may be true when decompiling bytecode produced directly from a specific compiler, most often Sun’s javac compiler. In this case it is really a matter of inverting a known compilation strategy. However, there are many problems, traps and pitfalls when decompiling arbitrary verifiable Java bytecode. Such bytecode could be produced by other Java compilers, Java bytecode optimizers or Java bytecode obfuscators. Java bytecode can also be produced by compilers for other languages, including Haskell, Eiffel, ML, Ada and Fortran. These compilers often use very different code generation strategies from javac.

This paper outlines the problems and solutions we have found in our development of Dava, a decompiler for arbitrary Java bytecode. We first outline the problems in assigning types to variables and literals, and the problems due to expression evaluation on the Java stack. Then, we look at finding structured control flow with a particular emphasis on issues related to Java exceptions and synchronized blocks. Throughout the paper we provide small examples which are not properly decompiled by commonly used decompilers.

Download to read the full conference paper text

Copyright information

© Springer-Verlag Berlin Heidelberg 2002

Authors and Affiliations

  • Jerome Miecznikowski
    • 1
  • Laurie Hendren
    • 1
  1. 1.Sable Research Group, School of Computer ScienceMcGill UniversityCanada

Personalised recommendations