The warning at the end of manual section 4.7 is relevant here:
Once you assert a jess.Fact object, you no longer "own" it - it
becomes part of the Rete object's internal data structures. As such,
you must not change the values of any of the Fact's slots. If you
retract the fact, the Fact object is released and you are free to
alter it as you wish.
The shadow fact that represents your Bean inside of Jess has the Date
object returned from getDateObject() in one of its slots. If you
modify this object, well, then basically anything can happen. Jess may
well be storing that Fact inside a kind of hash table, and changing
the value of a slot in that Fact will probably change the hash code of
the Fact, corrupting the data structure. Pretty much anything can
happen once Jess's innards have been misaligned.
Now, if you want to avoid the clone() call in the accessor, then in
the run() method of your Clock, don't directly modify the Date object;
create a new one with the new value.
I think Matthias Kallfass wrote:
> Hi all,
>
> I attached the source of a simple Clock bean that implements Runnable.
> In the source are two implementations of the getDateObject() method.
> METHOD 1 is working, METHOD 2 isn't and produces following watch output
> (batch clocktest.jess) :
>
> ==> f-0 (Clock (class <External-Address:java.lang.Class>) (date 18)
> (dateObject <External-Address:java.util.Date>) (day 2) (hours 21) (minutes 59) (month
> 9) (propertyChangeSupport <External-Address:java.beans.PropertyChangeSupport>)
> (seconds 0) (year 2001) (OBJECT <External-Address:jesstest.Clock>))
> ==> f-0 (Clock (class <External-Address:java.lang.Class>) (date 18)
> (dateObject <External-Address:java.util.Date>) (day 2) (hours 22) (minutes 0) (month
>9)
> (propertyChangeSupport <External-Address:java.beans.PropertyChangeSupport>)
> (seconds 0) (year 2001) (OBJECT <External-Address:jesstest.Clock>))
>
> As you can see the clock fact isn't retracted before the changed clock is
> reasserted. There are also multiple facts of this clock, all with the same
> fact-id.
>
> Q: Why isn't METHOD 2 working? Why have I to clone the date object?
>
> Jess Version: 6.0a5
>
> Thank You...
>
> Regards,
> Matthias
[Attachment, skipping...]
[Attachment, skipping...]
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
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]
---------------------------------------------------------------------