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

Reviewed-by: mcimadamore, jlahoda
This commit is contained in:
Aleksey Shipilev 2021-03-23 17:48:19 +00:00
parent d7268fa3a6
commit c087f3ed40

View File

@ -4076,17 +4076,13 @@ public class Types {
return buf.toList();
}
private Type arraySuperType = null;
private Type arraySuperType;
private Type arraySuperType() {
// initialized lazily to avoid problems during compiler startup
if (arraySuperType == null) {
synchronized (this) {
if (arraySuperType == null) {
// JLS 10.8: all arrays implement Cloneable and Serializable.
arraySuperType = makeIntersectionType(List.of(syms.serializableType,
syms.cloneableType), true);
}
}
// JLS 10.8: all arrays implement Cloneable and Serializable.
arraySuperType = makeIntersectionType(List.of(syms.serializableType,
syms.cloneableType), true);
}
return arraySuperType;
}