* Make Property.compareTo() immune against float/integer confusion, which is quite common in rhino.

This commit is contained in:
hns 2006-12-01 13:21:23 +00:00
parent aaa15f5670
commit bfdd643a99

View file

@ -513,6 +513,9 @@ public final class Property implements IProperty, Serializable, Cloneable, Compa
return -1; return -1;
} }
if (type != ptype) { if (type != ptype) {
// float/integer sometimes get mixed up in Rhino
if ((type == FLOAT && ptype == INTEGER) || (type == INTEGER && ptype == FLOAT))
return Double.compare(((Number) value).doubleValue(), ((Number) pvalue).doubleValue());
throw new ClassCastException("uncomparable values " + this + "(" + type + ") : " + p + "(" + ptype + ")"); throw new ClassCastException("uncomparable values " + this + "(" + type + ") : " + p + "(" + ptype + ")");
} }