On Thu, 14 Aug 2025 21:28:26 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
>> Remove javax.imageio.spi.ServiceRegistry.finalize() since it is deprecated >> for removal. >> The impact of this should be minimal. The IIORegistry will now be a >> singleton - which it already was >> in practice since Applets are no longer supported. Since it is a singleton, >> it will persist for the life >> of the VM, so will never be garbage collected. >> A test that verifies one per-AppContext is now obsolete, and is deleted, and >> there's no good reason to make it a negative test, since in due course >> AppContext itself will be deleted and is un-used today except in tests. >> >> Since JDK 9, ServiceRegistry has supported only Image I/O specified >> providers, and since the IIORegistry does this, >> in practice there is very little reason for an application to create >> instances or subclasses of it. >> And even if they do, typically like IIORegistry, they be used for the life >> time of the application. >> And if they are collected, without calling ServiceRegistry.deregisterAll() >> there may be no impact, >> since only providers that implement RegisterableService will be affected. >> >> See the JBS issue for all the details. >> >> The CSR is ready for review https://bugs.openjdk.org/browse/JDK-8365409 > > 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. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26752#discussion_r2279704926