On Sun, 27 Nov 2022 22:22:54 GMT, David Schlosnagle <[email protected]> wrote:
>> Field `javax.imageio.spi.IIORegistry#initialCategories` is modified only in
>> `static {}` block, which makes it effectively final. Instead of legacy
>> synchronized `Vector` we can use non-threadsafe `ArrayList` here.
>
> src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java line 89:
>
>> 87: * categories (superinterfaces) to be used in the constructor.
>> 88: */
>> 89: private static final ArrayList<Class<?>> initialCategories = new
>> ArrayList<>(5);
>
> Should this be an immutable list and remove the static block?
>
> Suggestion:
>
> private static final List<Class<?>> initialCategories = List.of(
> ImageReaderSpi.class,
> ImageWriterSpi.class,
> ImageTranscoderSpi.class,
> ImageInputStreamSpi.class,
> ImageOutputStreamSpi.class);
I think this one could be a better approach.
-------------
PR: https://git.openjdk.org/jdk/pull/11379