Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.sun.imageio.plugins.wbmp.WBMPImageWriterSpi;
import com.sun.imageio.plugins.tiff.TIFFImageReaderSpi;
import com.sun.imageio.plugins.tiff.TIFFImageWriterSpi;
import sun.awt.AppContext;
import java.util.List;
import java.util.ServiceLoader;
import java.util.ServiceConfigurationError;
Expand Down Expand Up @@ -105,25 +104,15 @@ private IIORegistry() {
registerApplicationClasspathSpis();
}

private static final IIORegistry registry = new 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() {
AppContext context = AppContext.getAppContext();
IIORegistry registry =
(IIORegistry)context.get(IIORegistry.class);
if (registry == null) {
// Create an instance for this AppContext
registry = new IIORegistry();
context.put(IIORegistry.class, registry);
}
return registry;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
* proxy for the heavyweight service.
*
* <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.
*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the above text is not related to finalization, but the text is meaningless since the SecurityManager was permanently disabled, so I will take this opportunity to remove it.

* <p> For information on how to create and deploy service providers,
* refer to the documentation on {@link java.util.ServiceLoader ServiceLoader}
Expand Down Expand Up @@ -283,8 +283,7 @@ public <T> boolean registerServiceProvider(T provider,
* {@code onRegistration} method will be called once for each
* category it is registered under. Its
* {@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.
*
* @param provider the service provider object to be registered.
*
Expand Down Expand Up @@ -313,8 +312,7 @@ public void registerServiceProvider(Object provider) {
* {@code onRegistration} method will be called once for each
* category it is registered under. Its
* {@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.
*
* @param providers an Iterator containing service provider
* objects to be registered.
Expand Down Expand Up @@ -660,33 +658,19 @@ public void deregisterAll(Class<?> category) {
/**
* Deregisters all currently registered service providers from all
* categories.
* <p>
* 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.
*/
public void deregisterAll() {
for (SubRegistry reg : categoryMap.values()) {
reg.clear();
}
}

/**
* 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 {
deregisterAll();
super.finalize();
}

/**
* Checks whether the provided class is one of the allowed
* ImageIO service provider classes. If it is, returns normally.
Expand Down Expand Up @@ -821,10 +805,6 @@ public synchronized void clear() {
poset.clear();
}

@SuppressWarnings("removal")
public synchronized void finalize() {
clear();
}
}


Expand Down
141 changes: 0 additions & 141 deletions test/jdk/javax/imageio/AppContextTest.java

This file was deleted.