JAR Bloat

I am surprised at how large the main client application JAR file is on my current Java project. I have a pile of source code which I have written over the last few months; it contains no generated code and no outside code (that stuff is in other jars).

This body of code results in a 506K JAR file. About 10% of that is because it is a “signed JAR” (An aside: it appears that signed jars actually actually sign each thing inside the JAR… much far higher overhead than .NET’s igned assemblies, which sign the whole thing as a chunk. I think .NET is on to something good with Assemblies with Sun missed with just-a-bunch-of-classes-in-a-JAR. Of course the latter has significant advantages also.)

Without the signing, the JAR is about 450K.

Javac optimization is on. There are ~350 classes in the JAR file. The JAR is compressed; wihtout compression it is around a megabyte.

– debug is on, so I get more helpful stack traces from the field when errant software somehow escapes our highly rigorous release process. Turning off debugdrops it to 424K signed / ~380K unsigned.

These numbers all seems enormous. The source code for the contents of this JAR, is only ~800K, and contain considerable comments, private identifiers, etc. My mental model of compilation suggests that it would produce tightly packed bytecode that tersely captures the executable essence of the source code in a small fraction of the bytes. This appears to not be the case.