I think Richard Kasperowski wrote: > > Hakim and I are working together on this. The scenario is: > - We create a Java object. > - We definstance a static shadow fact for it. > - We munge the Java object's properties. > - We retract the shadow fact. > - We definstance a new static shadow fact. > > Bear with us on retract-and-re-definstance. For various reasons, we > can't use dynamic shadow facts, so we retract and re-assert when > necessary. This led us to our problem. > > Mr. Fried's "hashCode() and/or equals()" is a good clue. When we munge > our Java object, though, we don't change its hashCode. The hashCode is > really a serial number that's set at constructor time; changing the > object's properties doesn't change the serial number. The object's > equals() implementation is basically "return hashCode1 == hashCode2", so > the two versions of the object are equals(). It looked like the clue > led to a dead end. > > But we followed it anyway. We changed our code to *retract* the shadow > fact *before* we *munge* the Java object's properties. Now the retract > works fine, so we're happy. > > We're still confused about why our *munging* the Java object *before* > *retracting* it makes it unretractable. We've solved our problem, > though, and we have to move on, so we're going to try to be happy > without fully understanding why our first pass didn't work. >
Some of your objects's slots contain Collections. If munging involves modifying the collections, their hashcodes will change, which will change the Fact's hashcode. This violates the "You can't change a Fact behind Jess's back" rule. This kind of issue is a pain when it comes up (which fortunately is not all that often.) I'm working on a plan for Jess 7 which will completely eliminate the problems -- at the expense of breaking some user code, unfortunately. --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
