-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
low
-
-
Java API
-
SE
Summary
javax.imageio.spi.ServiceRegistry.finalize() is removed.
Problem
Finalization is deprecated, but javax.imageio.spi.ServiceRegistry has a finalize() method.
Solution
- Remove the finalize() method.
- Document that if a ServiceRegistry is no longer needed, the application should call ServiceRegistry.deregisterAll()
- Remove from other methods javadoc, text related to the finalization behaviour
- Not related, but also update the class doc to remove obsolete reference to runtime permissions.
- Update the implementation and specification of javax.imageio.spi.IIORegistry.getDefaultInstance() so that it is now a singleton in all cases, and so never will be collected.
Specification
javax/imageio/spi/ServiceRegistry.java class doc
* <p> An application may customize the contents of a registry as it
- * sees fit, so long as it has the appropriate runtime permission.
+ * sees fit.
finalize method removal
- /**
- * Finalizes this object prior to garbage collection. The
- * {@code deregisterAll} method is called to deregister all
- * currently registered service providers. This method should not
- * be called from application code.
- *
- * @throws Throwable if an error occurs during superclass
- * finalization.
- *
- * @deprecated Finalization has been deprecated for removal. See
- * {@link java.lang.Object#finalize} for background information and details
- * about migration options.
- */
- @Deprecated(since="9", forRemoval=true)
- @SuppressWarnings("removal")
- public void finalize() throws Throwable
public void registerServiceProvider(Object provider)
* {@code onDeregistration} method will be called each time
- * it is deregistered from a category or when the registry is
- * finalized.
+ * it is deregistered from a category.
public void registerServiceProviders(Iterator<?> providers) {
* {@code onDeregistration} method will be called each time
- * it is deregistered from a category or when the registry is
- * finalized.
+ * it is deregistered from a category.
public void deregisterAll()
+ * If an application creates a new {@code ServiceRegistry} instance and registers providers,
+ * and at some point no longer needs the instance, it should call this method to ensure
+ * that all providers which are instances of {@link RegisterableService}
+ * receive a {@link RegisterableService#onDeregistration(ServiceRegistry, Class<?>)} call back,
+ * before allowing the instance to be garbage collected.
javax/imageio/spi/IIORegistry
/**
* Returns the default {@code IIORegistry} instance used by
* the Image I/O API. This instance should be used for all
* registry functions.
- *
- * <p> Each {@code ThreadGroup} will receive its own instance.
- *
- * @return the default registry for the current
- * {@code ThreadGroup}.
+ * @return the default registry for the Image I/O API
*/
public static IIORegistry getDefaultInstance()
- csr of
-
JDK-8365292 Remove javax.imageio.spi.ServiceRegistry.finalize()
-
- Open
-