Skip to content
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

GROOVY-9575 ASTNode.hashCode violates Object.hashCode contract: does not return consistent value #1260

Merged
merged 1 commit into from May 28, 2020

Conversation

awallgren
Copy link
Contributor

Remove unsuitable ASTNode.hashCode -- it does not conform to the Object
.hashCode general contract.

Remove unsuitable ASTNode.hashCode -- it does not conform to the Object
.hashCode general contract.
@daniellansun
Copy link
Contributor

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#hashCode()

Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.

As the javadoc of hashCode shows, "This integer need not remain consistent from one execution of an application to another execution of the same application."

@awallgren
Copy link
Contributor Author

awallgren commented May 28, 2020

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#hashCode()

Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.

As the javadoc of hashCode shows, "This integer need not remain consistent from one execution of an application to another execution of the same application."

I believe you are misreading that. It doesn't need to be consistent between invocations of the JVM itself (i.e. between different processes).

It should return the same value as long as no properties referenced in equals() change while invoked against the same object for the lifetime of the JVM process in which it was created.

@daniellansun daniellansun merged commit eb8539f into apache:master May 28, 2020
@daniellansun
Copy link
Contributor

Understood :-)
Merged. Thanks for your contributing.

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