Well, we assume that the standard hashCode()/equals() contracts are
met (see the java.lang.Object javadocs); in particular, that two
equals() objects always have the same hashCode(). Technically, this
means that two objects with the same hashCode() could be equals() at
one point, and then become un-equals() without the hashCode()
changing -- a perfectly legal contract-satisfying hashCode() method
returns a constant for all instances of a class, after all.
As far as Jess is concerned, such a class would still be a value
class. The important thing for Jess is that if it puts an object into
a bin based on hashCode(), then the object's hashCode() better not
change such that the object later finds itself in the wrong bin. If
that's a possibility, then Jess will ignore hashCode(), use the
identityHashCode() method instead, and assume each object of the
class is unique.
On Sep 20, 2007, at 9:47 PM, [EMAIL PROTECTED] wrote:
Is the only Jess requirement for a Java class to be a "value class"
that it have an immutable hashCode? (i.e., immutable for the JVM's
life?)
Or is there a deeper requirement that all the component values
affecting an equals comparison between two instances of the class
are immutable as well? Intuitively, a "value class" would seem to
be more restrictive than mere hash equivalence.
Ref http://herzberg.ca.sandia.gov/jess/docs/71/functions.html#set-
nonvalue-class
- Mike Smith
--------------------------------------------------------------------
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 owner-jess-
[EMAIL PROTECTED]
--------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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]
--------------------------------------------------------------------