You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Shan Jiang (Jira)" <ji...@apache.org> on 2026/03/06 02:33:00 UTC
[jira] [Created] (COMPRESS-719) `CPFloat`, `CPDouble`, `CPInt`, `CPLong`, `CPUTF8` — `compareTo` inconsistent with `equals`
Shan Jiang created COMPRESS-719:
-----------------------------------
Summary: `CPFloat`, `CPDouble`, `CPInt`, `CPLong`, `CPUTF8` — `compareTo` inconsistent with `equals`
Key: COMPRESS-719
URL: https://issues.apache.org/jira/browse/COMPRESS-719
Project: Commons Compress
Issue Type: Bug
Reporter: Shan Jiang
apache/commons-compress — Pack200 constant pool classes: compareTo inconsistent with equals
### Summary
Five constant pool classes in `org.apache.commons.compress.harmony.pack200` implement
`Comparable<T>` (via `CPConstant<T>`) with value-based `compareTo()`, but do not override
`equals()`. Two constants with the same value will have `compareTo()` return 0 but `equals()`
return false.
### Affected classes
| Class | compareTo compares by | File |
|-------|----------------------|------|
| `CPFloat` | `Float.compare(value, obj.value)` | `.../pack200/CPFloat.java` |
| `CPDouble` | `Double.compare(value, obj.value)` | `.../pack200/CPDouble.java` |
| `CPInt` | `Integer.compare(value, obj.value)` | `.../pack200/CPInt.java` |
| `CPLong` | `Long.compare(value, obj.value)` | `.../pack200/CPLong.java` |
| `CPUTF8` | `utf8.compareTo(obj.utf8)` | `.../pack200/CPUTF8.java` |
All extend `CPConstant<T>` which implements `Comparable<T>`.
### How this was found
Detected by an automated JDK conformance oracle (`ComparableOracles.checkCompareToEqualsConsistency`).
---
--
This message was sent by Atlassian Jira
(v8.20.10#820010)