Java source inside jars or classes?

Java source inside jars or classes?

I think every Java programmer has spent many, many hours being frustrated that a particular jar is missing source for the compiled classes. Many of the Java IDEs won’t let you set breakpoints if you lack source. The Maven infrastructure helps by standardizing putting the source jars next to the binary jars. But that still requires the IDE to need to fetch the sources separately, and sometimes they get confused about which source belongs to which jar (I’m looking at you, IntelliJ).

Disk is cheap. I propose that all open source Java projects should start bundling a source zip/jar inside of the jar of compiled classes. Or even better, it would be cool if the .class metadata allowed for the source code to be embedded so there would be zero ambiguity.

If this happened, it would be possible to attach an empty IDE to a running JVM and slurp all the source and start debugging. For proprietary software where you don’t want just anybody seeing the source, I propose that the embedded source zip be encrypted and a privileged developer could enter a password (or private key file) in the IDE to decrypt the source for debugging.

Cue the Perl/Python/Ruby folks saying “huh, I’ve never had that problem”. 🙂