On Wed, 3 Mar 2021 03:46:59 GMT, Sergey Bylokhov <[email protected]> wrote:
> The java.awt.color.ColorSpace.getName() method does not use any kind of
> synchronization to properly initialize and use the static cache for the color
> components names.
src/java.desktop/share/classes/java/awt/color/ColorSpace.java line 115:
> 113: * Lazy-initialized names of components in the color space.
> 114: */
> 115: private transient volatile String [] compName;
The volatile keyword is the only one necessary to fix this bug, everything else
is a cleanup.
src/java.desktop/share/classes/java/awt/color/ColorSpace.java line 454:
> 452: * Returns the name of the component given the component index.
> 453: *
> 454: * @param component the component index
All other methods use the "component" as a name of the component index.
src/java.desktop/share/classes/java/awt/color/ColorSpace.java line 459:
> 457: rangeCheck(idx);
> 458: if (compName == null) {
> 459: switch (type) {
the "switch statement" is replaced by the "switch expression"
-------------
PR: https://git.openjdk.java.net/jdk/pull/2801