-
Notifications
You must be signed in to change notification settings - Fork 433
Fix missing hashCode implementations for SpotBugs compliance #4316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix missing hashCode implementations for SpotBugs compliance #4316
Conversation
Implemented proper hashCode() methods in classes overriding equals(): - Geofence: Uses ID, radius, expiration, and location coordinates. - PropertyBase: Uses name. - Font: Uses font properties (face, size, style) or native font hash. - Border: Uses type, color, thickness, arc, etc. - Style: Uses visual properties (colors, font, background). - TarEntry: Added equals(Object) and hashCode based on header name. - CustomFont: Uses charset and cutOffsets. - Transform: Uses type and transformation matrix values. - CSSBorder (and inner classes): Uses identity hash or field hashes. - RoundBorder/RoundRectBorder: Uses identity hash (consistent with equals). - ImageDownloadService: Uses cacheId. - Layouts (Border, Box, Flow, Grid, Table): Use layout properties.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
|
Compared 30 screenshots: 30 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
|
…classes - Implemented consistent `hashCode()` and `equals()` for: - `Geofence`: uses id, location, radius, expiration. - `PropertyBase`: uses name. - `Font`: uses native font or attributes. - `Border` / `CSSBorder` / `RoundBorder`: uses fields or identity where appropriate. - `Style`: manual hash calculation for primitive arrays (margin/padding) to avoid missing Arrays utility in CLDC. - `TarEntry`: added `equals(Object)` override and `hashCode` based on header name. - `Transform`: uses type and matrix values. - `ImageDownloadService`: uses cacheId. - `BoxLayout`: added `align` to equals/hashCode to fix layout update issues. - `BorderLayout`, `FlowLayout`, `GridLayout`, `TableLayout`: uses configuration fields. - Fixed `BoxLayout` equality check to include alignment, resolving layout update regression. - Manual array hashing in `Style` ensures CLDC 1.1 compatibility.
- Reverted `Style.hashCode` to use `System.identityHashCode(this)` to prevent regressions in layout and caching caused by value-based hashing of mutable UI state. - Reverted `BoxLayout` equality to ignore `align` (matching previous behavior) to resolve test failures. - Implemented consistent `hashCode()` for: - `Geofence`: uses id, location, radius, expiration. - `PropertyBase`: uses name. - `Font`: uses native font or attributes. - `Border` / `CSSBorder` / `RoundBorder`: uses fields or identity where appropriate. - `TarEntry`: added `equals(Object)` override and `hashCode`. - `Transform`: uses type and matrix values. - `ImageDownloadService`: uses cacheId. - `BorderLayout`, `FlowLayout`, `GridLayout`, `TableLayout`: uses configuration fields.
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| int hash = 7; | ||
| hash = 29 * hash + this.type; | ||
| hash = 29 * hash + (this.nativeTransform != null ? this.nativeTransform.hashCode() : 0); | ||
| hash = 29 * hash + Float.floatToIntBits(this.translateX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align Transform hashCode with equals
The new equals(Object) now delegates to transformEqualsImpl, which compares the underlying matrix values, but hashCode() still relies on nativeTransform.hashCode(). On Android (and other ports), nativeTransform is a CN1Matrix4f that implements value-based equals but inherits the default identity hash code. As a result, two transforms constructed separately with identical matrix data (e.g., the same translation/scale) will compare equal yet return different hash codes, breaking lookups in hashed collections that rely on the new equality semantics.
Useful? React with 👍 / 👎.






This PR resolves multiple SpotBugs warnings regarding missing or inconsistent
hashCode()implementations in classes that overrideequals().Changes include:
hashCodeusing ID, radius, expiration, and lat/long from Location (since Location lacks hashCode).hashCodeusing property name.hashCodemirroringequalslogic (native font or attributes).hashCodeusing visual attributes.hashCodeusing relevant style attributes.equals(Object)(to fix overloading issue) andhashCodeusing header name.hashCodeusing charsets and cutOffsets.equals(Object)andhashCodeusing transformation type and values.hashCodefor main class (identity) and inner classes (field-based).hashCodeusing identity, matching their identity-basedequals.hashCodeusingcacheId.hashCodetoBorderLayout,BoxLayout,FlowLayout,GridLayout, andTableLayoutbased on their configuration fields.PR created automatically by Jules for task 16301786647297229349 started by @shai-almog