RFR: 8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not thread safe

liach duke at openjdk.org
Mon Feb 20 13:12:25 UTC 2023


On Sun, 19 Feb 2023 18:41:18 GMT, liach <duke at openjdk.org> wrote:

> 8302822: Method/Field/Constructor/RecordComponent::getGenericInfo() is not thread safe

We don't fear calling the factory twice for benign races, as the distinct constructor factory instances are behaviorally the same.

The true issue lies in the double getfield operations: Java memory model doesn't require the second read to happen-after a write reflected in the first read, so return this.genericInfo may return null while this.genericInfo == null evaluates to false, in case genericInfo is initialized lazily by another thread. See https://bugs.openjdk.org/browse/JDK-8261404

-------------

PR: https://git.openjdk.org/jdk/pull/12643


More information about the core-libs-dev mailing list