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

  • The Colder Side of Spring

    It was supposed to be getting warmer for Spring, but the weather appears to have other ideas this week. There's a freeze warning tonight, so I went…

  • Out to Lunch

    Gretchen and I were casting about for something different to have for lunch today. I have been craving a good smoked brisket sandwich and my Internet…

  • Bits and Pieces

    Got up early today for softball practice. The second half was a scrimmage with one of the other local teams, which was a good learning experience for…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded