Bill Roper (billroper) wrote,
Bill Roper

Thud, Thud, Thud

I've been trying to beat the bugs out of a Java demo that I'm supposed to do on Monday. This was complicated by socket connections between client and server gleefully timing out whenever I stopped to debug, but one of my compatriots sent me the proper registry settings to fix that problem and debugging became much more tractable.

Unfortunately, the MFC serialization code that I wrote in Java was writing an ID that was causing a problem on the C++ side of the world. Specifically, an ID that was supposed to be unique had shown up on the client side as shared. And when the second attempt was made to delete the same object, well, nothing good at all happened.

I spent a lot of time making sure that all of the IDs and objects were being correctly cloned on the Java side, but no luck.

Ok. Maybe there was a problem in serialization. I traced into the writing code and discovered that I was using a HashMap to store objects so that I could (like the C++ MFC serialization) detect when I was serializing the same object twice and write a reference to it the second time.

But the HashMap calls the hashCode() function for the object on the Java side. And I had overridden the hashCode() function for a couple of the ID objects, because I wanted to make sure that two IDs that contained the same strings would locate the same hash bucket. And this meant that the HashMap in serialization thought they were the same object. So when I encountered the second unique object and wrote it out to the MFC archive, my serialization code wrote a reference to the first object.

Thud. Thud. Thud.

I have now spent the last several hours beating up all of my HashMap code that stored these various IDs so that they now store the keys as Strings. The overriding hashCode() methods have been exterminated.

And maybe this will work now.

Tags: java, mfc, musings, work

  • Time for Rebuilding

    Well, there's nothing like research. Having determined that DDR5 is going to carry a substantial price premium over DDR4 memory for at least a year…

  • Driven Wild

    The studio computer continues to misbehave in various ways. When I fired up Cubase today, I got a lot of nasty, blocky video, despite having cleaned…

  • Some Old Doggerel

    I recall having mangled a CSN tune many years ago on the way to Contraption. Like that convention, the particular co-worker whose code I was digging…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded