About this site
















Decompiling Java

Wednesday, February 19, 1997 by Dave Winer.

An exciting, fascinating, and then sad story started unveiling yesterday.

It began with an excited phone call from a friend who has been working in Java for the last few months. He found a program on the net called Mocha that can be used to decompile Java apps. He was psyched! Learning a lot about Java by looking at the source code of apps downloaded from the net.


A decompiler undoes the work of a compiler. It takes a machine-executable program and turns it into source code. For most languages, such as C or Pascal, the resulting decompiled program is quite artificial, and can't really be used to reverse-engineer the program that was decompiled. This is one of the most important ways commercial developers protect the intellectual property value of the software they distribute.

It turns out, due to a quirk in the design of the Java Runtime system and the relationship with its compilers, that Java code can be almost entirely reconstructed, including the actual names of variables used by the original programmer! The only things missing are the comments. This is an amazing oversight in the architecture of Java. Why is it this way? I don't know. I'd be interested in hearing more.

My friend had used Mocha to decompile one of the most widely publicized commercial Java apps, so we know that the process works.

I published a link to Mocha, alongside a reference to an Infoworld article detailing a huge committment by IBM to Java. I wondered if they knew that anyone could decompile their Java code and learn all their secrets? I bet they didn't.

There's more to the story Permalink to There's more to the story

I got mail from Sidney Markowitz, sidney@research.apple.com, pointing me to a C|Net article on the controversy, from back in August 1996 when Mocha first appeared.

Sidney pointed me to a page with an explanation by Hanpeter van Vliet, the author of Mocha, which begins "The Dutch have a reputation for stealing coffee. Exactly three centuries ago, in 1696, my ancestors stole a coffee plant from the heavily guarded plantations of Mocha (Yemen). They shipped it to their east-Indian colony and cultivated it into a unique and successful species that would become known as Java.

"So what could be more appropriate to celebrate this than to release Mocha, the Java decompiler, this year? And isn't it apt that both the Java compiler and decompiler were written by Dutchmen? Not everybody seems to agree."


It's a fascinating piece. Well worth reading. Read the piece, you'll understand how he did it, and why Java is an exceptionally public programming language. Without scrambling the source code, it's impossible to keep Java source code private.

Markowitz writes: "The page you gave for the Mocha decompiler was set up last August and points to the author's home page site, which no longer has an account under his name. I did some web searching and found more news about Mocha, some of it quite sad.

From the Usenet newsgroup comp.lang.java.advocacy yesterday:

The question, "The Mocha web page has gone 404. Anyone know why?"

Johan Vromans, johan_vromans@nl.compuware.com, said: "Hanpeter van Vliet, author of Mocha and owner of the page, died December 31st. He was a colleague of mine."

Takes my breath away.

Dave Winer

© Copyright 1994-2004 Dave Winer. Last update: 2/5/07; 10:50:05 AM Pacific. "There's no time like now."