Thursday, April 30, 2009

Recovery and JAD

Oh, how frustrating.

I was working on a minor bug fix; nothing big, nothing complex, just a little bit of work. I had been back-and-forth on the fix several times over a period of a few weeks, working with the system test team to get it just right.

I finally got the fix to a reasonable state.

Unfortunately, the codeline was closed at that point, so I couldn't submit the fix (it's targeted for a future release this summer).

And, the fix doesn't apply to any other releases, neither to older releases nor to the current trunk (it's highly release-specific, as it covers an edge case that only arises in upgrading to this particular release), so I didn't need to submit it to any other branches.

So, I just left the bug fix in my client, as a set of checked-out files.

If I had been smart, I would have run 'p4 diff' and saved the output somewhere, perhaps as an attachment in our bug-tracking system. But our internal bug-tracking system is really awkward and unpleasant to use, so I didn't do that. Dumb.

If I had been smart, I would have put the fix into a branch, for safekeeping. But creating a branch, although fairly lightweight, is still a bunch of work, and I was feeling lazy, so I didn't do that. Dumb.

If I had been smart, I would have set up a Git repository on my own machine, so I could check the fix into something somewhere, but Git is still very new to me, and I didn't do that. Dumb.

So I just left the bug fix in my client.

Unfortunately, I am often doing eight things at once, trying out various little bits of code on various projects in various ways. So it's quite common for me to make a change, evaluate it, think about it, and then revert it and move on to something else.

Unfortunately, I did that. And, accidentally, I reverted my bug fix, in the process. So I lost the changes. Dumb.

However, there is a glimmer of hope. Since I was working with the test team, I still have a copy of the binary release kit that I built for them to evaluate the fix. And, there is this marvelous tool called Jad, which can take a Java class file and de-compile it, to produce Java source code.

So, I think I can use the following technique:
  • Use Jad to decompile the relevant classes from my working kit
  • Use Jad to decompile the same classes from the standard release kit
  • diff the jad output, and attempt to recover my fix from that.
I'm hopeful. I'll give it a try, and see how it goes. Better than trying to re-code the fix from scratch. And, this time, I'll put the fix in a branch, since there's no telling when the release codeline will be open for fixes for the next version.

Jad is a nifty tool; I've used it a lot. But it seems to be "abandonware" at this point. That's too bad. I wonder what people use nowadays. There appear to be a number of alternatives. Or does everyone just run javap?

No comments:

Post a Comment