# hashCode

The Java Object.hashCode() method returns a hash code value for an object and supports hash tables such as HashMap.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Clojure 1.11.2

DevFeed: [Clojure 1.11.2](<https://devfeed.tech/articles/clojure-1-11-2-49666.md>)

Original publisher: [Read original article](<https://clojure.org/news/2024/03/08/clojure-1-11-2>)

Published: 2024-03-08T00:00:00Z

Content type: release

Language: en

Sources: [Clojure News](<https://devfeed.tech/sources/clojure-news.md>)

Topics: [Clojure](<https://devfeed.tech/topics/clojure.md>), [releases](<https://devfeed.tech/topics/releases.md>), [hashCode](<https://devfeed.tech/topics/hashcode.md>)

Tags: [clojure](<https://devfeed.tech/tags/clojure.md>), [cve](<https://devfeed.tech/tags/cve.md>), [hashcode](<https://devfeed.tech/tags/hashcode.md>), [infinite](<https://devfeed.tech/tags/infinite.md>), [programming](<https://devfeed.tech/tags/programming.md>), [releases](<https://devfeed.tech/tags/releases.md>), [repeat](<https://devfeed.tech/tags/repeat.md>)

### AI overview

Clojure 1.11.2 and 1.12.0-alpha9 are available with a fix for CVE-2024-22871, addressing infinite hashCode() computation for infinite sequences produced by iterate, cycle, and repeat.

### Source excerpt

Clojure 1.11.2 and 1.12.0-alpha9 are now available. These releases include a fix for CVE CVE-2024-22871 detailed in GHSA-vr64-r9qj-h27f: CLJ-2839 - iterate, cycle, repeat - infinite seqs have infinite hashCode()

## On Generating Identity Hash Codes

DevFeed: [On Generating Identity Hash Codes](<https://devfeed.tech/articles/on-generating-identity-hash-codes-24843.md>)

Original publisher: [Read original article](<https://alidg.me/blog/2020/7/15/hash-code>)

Author: Alimate

Published: 2020-07-15T00:00:00Z

Content type: article

Language: en

Sources: [Ali Dehghan - Kemikit](<https://devfeed.tech/sources/ali-dehghan-kemikit.md>)

Topics: [hashCode](<https://devfeed.tech/topics/hashcode.md>), [hashing](<https://devfeed.tech/topics/hashing.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [computational complexity](<https://devfeed.tech/topics/computational-complexity.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [cas](<https://devfeed.tech/tags/cas.md>), [experimental](<https://devfeed.tech/tags/experimental.md>), [flag](<https://devfeed.tech/tags/flag.md>), [function](<https://devfeed.tech/tags/function.md>), [generate](<https://devfeed.tech/tags/generate.md>), [generator](<https://devfeed.tech/tags/generator.md>), [hash](<https://devfeed.tech/tags/hash.md>), [hashcode](<https://devfeed.tech/tags/hashcode.md>), [hotspot](<https://devfeed.tech/tags/hotspot.md>), [identity](<https://devfeed.tech/tags/identity.md>), [java](<https://devfeed.tech/tags/java.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [memory](<https://devfeed.tech/tags/memory.md>), [random](<https://devfeed.tech/tags/random.md>), [retry](<https://devfeed.tech/tags/retry.md>), [threads](<https://devfeed.tech/tags/threads.md>), [variable](<https://devfeed.tech/tags/variable.md>)

### AI overview

HotSpot JVM's identity hash code generation strategy is controlled by an experimental tuning flag, and the excerpt describes several approaches. The Park-Miller/Lehmer RNG strategy atomically updates a global seed; concurrent first-time hash requests can cause compare-and-swap failures and retries. Two strategies derive the hash code from a function of the object's memory address. A static-number strategy always returns 1, which the author guesses may serve as a benchmark baseline. The excerpt begins to introduce a sequential-number strategy but cuts off before explaining it, and omits code and values needed to detail the other strategies.

### Source excerpt

Have you ever wondered how does the HotSpot JVM generate identity hashcodes?

## A Canonical equals() For Java

DevFeed: [A Canonical equals() For Java](<https://devfeed.tech/articles/a-canonical-equals-for-java-32219.md>)

Original publisher: [Read original article](<https://bruceeckel.com/2017/01/07/a-canonical-equals-for-java/>)

Author: Bruce Eckel

Published: 2017-01-07T00:00:00Z

Content type: article

Language: en

Sources: [Bruce Eckel - Computing Thoughts](<https://devfeed.tech/sources/bruce-eckel-computing-thoughts.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [hashCode](<https://devfeed.tech/topics/hashcode.md>)

Tags: [canonical](<https://devfeed.tech/tags/canonical.md>), [code](<https://devfeed.tech/tags/code.md>), [comparisons](<https://devfeed.tech/tags/comparisons.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [equals](<https://devfeed.tech/tags/equals.md>), [examples](<https://devfeed.tech/tags/examples.md>), [hashcode](<https://devfeed.tech/tags/hashcode.md>), [java](<https://devfeed.tech/tags/java.md>)

### AI overview

A concise `equals()` can use `instanceof` followed by short-circuiting `&&` comparisons with `Objects.equals()`: the type check rejects `null` and incompatible types, and a self-comparison succeeds through matching fields. The article says to choose fields as part of class design and keep `equals()` and `hashCode()` aligned for hashed collections. Its `Pet` example shows that a base-class equality definition can make a `Dog` and `Pig` with matching fields collapse into one `HashSet` entry; including a unique ID in both methods or defining subtype-specific `equals()` preserves both. The excerpt also notes that mutable comparison fields can disrupt hashed lookup behavior.

### Source excerpt

Even with the help of Java 7's Objects.equals(), the equals() method is often written in a verbose and messy fashion. This article shows how you can write a succinct equals() in a format that allows easy checking with visual inspection. When you create a new class, it automatically inherits class Object. If you don't override equals(), you'll get Objects equals() method. By default this compares addresses, so only if you are comparing the exact same objects will you get true.

## The Java IAQ

DevFeed: [The Java IAQ](<https://devfeed.tech/articles/the-java-iaq-40570.md>)

Original publisher: [Read original article](<http://norvig.com/java-iaq.html>)

Published: 2005-08-08T00:00:00Z

Content type: article

Language: en

Sources: [Peter Norvig](<https://devfeed.tech/sources/peter-norvig.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [hashCode](<https://devfeed.tech/topics/hashcode.md>), [iteration](<https://devfeed.tech/topics/iteration.md>), [conditionals](<https://devfeed.tech/topics/conditionals.md>), [Regular expression](<https://devfeed.tech/topics/regular-expression.md>)

Tags: [java](<https://devfeed.tech/tags/java.md>), [questions](<https://devfeed.tech/tags/questions.md>)

### AI overview

The Java IAQ answers obscure Java questions with examples of behaviors that can surprise programmers. It explains that `finally` is not guaranteed to run in every case, `this.getClass()` can return a subclass, and `Hashtable` lookup requires a correctly overridden `equals(Object)` plus a consistent `hashCode`. It also shows how inherited methods such as `Hashtable.put` can dispatch back into an overriding subclass method, and why `Properties.getProperty` consults defaults while inherited `get` does not. For inheritance, it recommends checking superclass contracts and considering delegation, which offers more control at the cost of extra code and reuse. Further sections cover alternatives to global variables, `null`, initialization order, constructor design, factories and object recycling, and performance observations explicitly tied to 1998-era JDK 1.1.4 measurements; those timings may not reflect later compilers.

### Source excerpt

Infrequently Answered Questions for Java