Skip to content

Make identity hashing aware of JavaProxy #8614

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

headius
Copy link
Member

@headius headius commented Feb 5, 2025

This change makes compare_by_identity Hash instances know about our JavaProxy wrapper type and treat as identical two wrappers that contain the same object. This will add overhead to all identity hashes in order to type check the incoming keys:

  • It must know to calculate the identity hash based on the contained object and not the wrapper (affects all identity Hash).
  • It must also try to unwrap proxies and compare contents when traversing existing entries (only affects identity Hash when a key does not already exist).

This fixes the identity Hash portion of #8612.

This change makes compare_by_identity Hash instances know about
our JavaProxy wrapper type and treat as identical two wrappers
that contain the same object. This will add overhead to all
identity hashes in order to type check the incoming keys:

* It must know to calculate the identity hash based on the
  contained object and not the wrapper (affects all identity Hash).
* It must also try to unwrap proxies and compare contents when
  traversing existing entries (only affects identity Hash when a
  key does not already exist).

This fixes the identity Hash portion of jruby#8612.
@headius headius marked this pull request as draft February 5, 2025 22:58
@headius headius added this to the JRuby 9.4.12.0 milestone Feb 7, 2025
@headius
Copy link
Member Author

headius commented Feb 7, 2025

This needs tests but I think we are pretty safe including it in an upcoming release. It does not appear to be necessary to fix issues in @kalenp's application, so there's no rush to include it in 9.4.12.0.

After discussion we decided that we could not think of a case where someone would not want two equivalent Java object wrappers to appear identical to an identity Hash, and lots of reasons why that behavior is almost certainly unexpected. Since currently it's just broken, as illustrated by my example in #8612, this is a net positive functionality fix.

Note I have not done any benchmarking to see how the additional type-checking affects identity Hash performance, so that should happen before merge as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy