On Fri, 15 Aug 2025 19:05:32 GMT, Phil Race <[email protected]> wrote:
>> src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java line 109:
>>
>>> 107: private static final IIORegistry registry;
>>> 108: static {
>>> 109: registry = new IIORegistry();
>>
>> Constructor of IIORegistry executes a large amount of code, might be better
>> to load it lazily as before? instead of from the class initialization. could
>> be a good opportunity to use StableValue?
>
> I thought about that whilst making the change, but
> (1) The javax.imagio.ImageIO class has this code
>
> private static final IIORegistry theRegistry =
> IIORegistry.getDefaultInstance();
>
> So it is going to get initialized really early on in virtually all uses of
> ImageIO, so doing as I did seems fine.
>
> (2) The code in getDefaultInstance() is now going to run 1,000 times faster
> than it did before so stable value to get it running 2,000 times faster
> probably is not necessary. And in any case, the version cached on ImageIO is
> what is going to be used. Hmm, it probably should not have been doing that as
> it defeated the AppContext, but it doesn't matter now.
I am not worried much about performance, but I am concerned about the
possibility of a deadlock in static initializers, since the services loaded by
the IIORegistry can trigger any code.
btw why not "private static final IIORegistry registry = new IIORegistry();"?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26752#discussion_r2279797615