RFR: 8263995: Incorrect double-checked locking in Types.arraySuperType()

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Mar 22 18:33:38 UTC 2021

On Mon, 22 Mar 2021 18:19:39 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> In Types.arraySuperType(), SonarCloud reports:
>  Remove this dangerous instance of double-checked locking.
> Indeed, the `arraySuperType` is not `volatile`, while `IntersectionClassType` has non-`final` fields (both in itself and in superclasses). This is an incorrect DCL.

I'm a bit surprised to see use of volatile/synchronized here as I'm pretty sure that javac is *not* thread safe.
It seems like the synchronized block has been there from a long time (e.g. it was there since the dawn of OpenJDK :-)). I wonder if a better fix would be simply to drop synchronization and volatileness.


PR: https://git.openjdk.java.net/jdk/pull/3129

More information about the compiler-dev mailing list