Bile stains …

The BileBlog is in full swing today and the bile is splashing dangerously close to me. It’s all good fun and this is a good opportunity to explain a few things.

Firstly let me say why Clover generates multiple files. Clover can be active in multiple VMs at the same time. Each VM will generate it’s own coverage information file. Those VMs could be running on multiple machines with different operating systems using a shared drive. Indeed it’s even possible that Clover could be running in multiple class loaders within the same VM. Could you write to a single file in those circumstance? If you could, would it be worth the testing effort to make sure it works. Since Clover has to work across multiple runs anyway, we just make it work that way in all cases. If jCoverage is using a single file, I’m not sure how they can support these sorts of scenarios. You need to look beyond your own usecases.

Now for the AntClassLoader. It is pretty ugly but, hey, one must love one’s creations. What can I say – you live and learn. In an open source project which values backward compatibility, your code, good and bad, tends to stay around for everyone to peek into.

There are reasons why the AntClassLoader is the way it is. One is that it needed to compile under JDK 1.1 which meant that some ClassLoader nicities weren’t available. Using reflection always results in ugly code. It’s a rock and a hard place – 1.2 users want to set the context class loaders etc, while 1.1 users want Ant to work for them. We kept that going for as long as we could, probably too long but we are now finally leaving 1.1 behind. The other complexities come about because I tried to make the <java> task work the same regardless of whether it was forked or not. If something causes a ClassNotFoundException when forked, users wanted it to behave the same way when not forked. They didn’t want classes visible due to Ant to be visible to their java tasks. The AntClassLoader has some features to maintain this illusion. It mostly works although it is a path leads to the vortex of Linkage Errors.

Complexity has accumulated in the AntClassLoader but a clean rewrite has its own issues. Things are in the code for a reason. Again you need to think beyond your own usecases.

The rest of the bile actually contains some very useful tips for building good Ant build files. Read it.