4 ms·
It can catch people by surprise that Java's narrowing conversions may not preserve the sign. For example, the following is broken: class TimestampedObject impl
by irogers 5y ago
It can catch people by surprise that Java's narrowing conversions may not preserve the sign. For example, the following is broken:
class TimestampedObject implements Comparable<TimestampedObject> {
long timestamp;
int compareTo(TimestampedObject other) {
return (int)(timestamp - other.timestamp);
}
...
}
ErrorProne catches this: https://errorprone.info/bugpattern/BadComparable https://errorprone.info/bugpattern/BadComparable