[
https://issues.apache.org/jira/browse/COMPRESS-719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory updated COMPRESS-719:
-------------------------------------
Summary: CPConstant subclasses are missing optional hashCode() and equals()
(was: `CPFloat`, `CPDouble`, `CPInt`, `CPLong`, `CPUTF8` — `compareTo`
inconsistent with `equals`)
> CPConstant subclasses are missing optional hashCode() and equals()
> ------------------------------------------------------------------
>
> Key: COMPRESS-719
> URL: https://issues.apache.org/jira/browse/COMPRESS-719
> Project: Commons Compress
> Issue Type: Bug
> Reporter: Shan Jiang
> Priority: Major
>
> 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)