Skip to content

Commit aebaf39

Browse files
Fix invalid shift in PropertyIndex.hashCode (#4314)
This commit fixes a bug in `PropertyIndex.hashCode()` where a 32-bit integer was being shifted by 32 bits (`b >>> 32`). In Java, shifting an `int` by 32 is a no-op (mod 32), leading to `b ^ b` which results in 0. This caused the property values to be effectively ignored in the hash code calculation. The fix removes the invalid shift and XOR operation, using the property hash code directly (`value = 31 * value + b`), which is the standard way to accumulate hash codes. This ensures that `PropertyIndex` objects with different property values have different hash codes. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent f4e9392 commit aebaf39

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CodenameOne/src/com/codename1/properties/PropertyIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ public int hashCode() {
859859
Object v = properties[iter].get();
860860
if (v != null) {
861861
int b = v.hashCode();
862-
value = 31 * value + (b ^ (b >>> 32));
862+
value = 31 * value + b;
863863
}
864864
}
865865
}

0 commit comments

Comments
 (0)