-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[pigeon] Fixes support for Kotlin/Java classes that override equals and hashCode for ProxyApis #10039
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
Merged
Merged
[pigeon] Fixes support for Kotlin/Java classes that override equals and hashCode for ProxyApis #10039
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c828fff
override fix
bparrishMines 3300041
add log and version bump
bparrishMines dcb38bc
Merge branch 'main' of github.com:flutter/packages into pigeon_overri…
bparrishMines 6d21fdd
better solution for equality
bparrishMines c369826
Merge branch 'main' of github.com:flutter/packages into pigeon_overri…
bparrishMines b4fa524
fix pigeonVersion
bparrishMines 3508c81
switch to identity hash code
bparrishMines 906b638
Merge branch 'main' of github.com:flutter/packages into pigeon_overri…
bparrishMines 39db552
use a shared weakreference object
bparrishMines 2e7258f
resort to using the saved hashcode and using the actual instance
bparrishMines b36e36c
Merge branch 'main' of github.com:flutter/packages into pigeon_overri…
bparrishMines 643f547
add tests for class
bparrishMines e10b405
another test and more docs
bparrishMines 38efe0f
Merge branch 'main' of github.com:flutter/packages into pigeon_overri…
bparrishMines f33dd17
create a local method for logging
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
better solution for equality
- Loading branch information
commit 6d21fdd1e5a001e3767d797e35c3493f216b0b54
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
hashCodeimplementation forIdentityKeyhas a critical bug and a logical inconsistency.WeakReferencehas been cleared by the garbage collector,instance.get()will returnnull. Calling.hashCode()onnullwill result in aNullPointerException. Theequalsmethod correctly handles this case, buthashCodedoes not.IdentityKeyis to enforce identity-based equality, similar toIdentityHashMap. Therefore, its hash code should also be based on identity. Using the instance's ownhashCode()can lead to unnecessary hash collisions if different instances have the same value-based hash code, and it deviates from the principle of identity-based hashing.The correct approach is to use
System.identityHashCode(), which is safe fornullinputs (it returns 0) and provides an identity-based hash code.