Monday, February 07, 2011

Stupid bugs from conflicting classes

A few days back, one of our systems started behaving weird. I can't explain what all happened, but it was weird. Anyway, we put logging statements, changed the input parameters etc and tested it on one of our development machines. Nothing happened. To our surprise, even some logging statements were missing. We rechecked the build process and made sure, eclipse is REALLY REALLY building this thing. Console logs said, it was REALLY REALLY building it. Hmm.. so, what might be wrong :-? After thinking for a while, I asked the developer if he had copied/reused any code. "Aaa.. Umm... yes.. I had copied one XXXX class...". lol! He copied the entire class along with the package structure. What should I say, copy/paste helps and kills too. I know, this level of copy/paste is not at all acceptable, but again, fresher, deadlines, pressure etc.

To not to repeat this mistake again, I wrote a small Java Program which reads all the jar files in a directory and prints out any conflicting classes along with the jar file name. Link below.

- yam

No comments: