--- old/src/share/classes/javax/imageio/spi/ServiceRegistry.java 2014-02-12 10:14:17.604036817 +0000
+++ new/src/share/classes/javax/imageio/spi/ServiceRegistry.java 2014-02-12 10:14:17.340036823 +0000
@@ -123,15 +123,6 @@
}
}
- // The following two methods expose functionality from
- // sun.misc.Service. If that class is made public, they may be
- // removed.
- //
- // The sun.misc.ServiceConfigurationError class may also be
- // exposed, in which case the references to 'an
- // Error
' below should be changed to 'a
- // ServiceConfigurationError
'.
-
/**
* Searches for implementations of a particular service class
* using the given class loader.
--- old/src/share/classes/javax/sound/midi/MidiSystem.java 2014-02-12 10:14:18.268036802 +0000
+++ new/src/share/classes/javax/sound/midi/MidiSystem.java 2014-02-12 10:14:18.004036808 +0000
@@ -1475,7 +1475,7 @@
/**
* Obtains the set of services currently installed on the system
- * using sun.misc.Service, the SPI mechanism in 1.3.
+ * using the SPI mechanism in 1.3.
* @return a List of instances of providers for the requested service.
* If no providers are available, a List of length 0 will be returned.
*/
--- old/src/share/classes/javax/sound/sampled/AudioSystem.java 2014-02-12 10:14:18.936036786 +0000
+++ new/src/share/classes/javax/sound/sampled/AudioSystem.java 2014-02-12 10:14:18.672036792 +0000
@@ -1622,7 +1622,7 @@
/**
* Obtains the set of services currently installed on the system
- * using sun.misc.Service, the SPI mechanism in 1.3.
+ * using the SPI mechanism in 1.3.
* @return a List of instances of providers for the requested service.
* If no providers are available, a vector of length 0 will be returned.
*/
--- old/test/sun/misc/JarIndex/metaInfFilenames/Basic.java 2014-02-12 10:14:19.624036771 +0000
+++ new/test/sun/misc/JarIndex/metaInfFilenames/Basic.java 2014-02-12 10:14:19.344036777 +0000
@@ -24,7 +24,7 @@
/*
* @test
* @bug 6887710
- * @summary Verify the impact of sun.misc.JarIndex.metaInfFilenames on Service loaders
+ * @summary Verify the impact of sun.misc.JarIndex.metaInfFilenames on ServiceLoader
* @run main/othervm Basic
*/
@@ -48,9 +48,8 @@
import com.sun.net.httpserver.HttpServer;
/**
- * Verifies the impact of sun.misc.JarIndex.metaInfFilenames on service loaders
- * (sun.misc.Service & java.util.ServiceLoader), as well as finding resources
- * through Class.getResouce.
+ * Verifies the impact of sun.misc.JarIndex.metaInfFilenames on ServiceLoader
+ * and on finding resources via Class.getResource.
*
* 1) Compile the test sources:
* jarA:
@@ -214,23 +213,13 @@
int failed = 0;
- // Tests using sun.misc.Service
- if (!sunMiscServiceTest(baseURL, messageService, true, false, true)) {
- System.out.println("Test: sun.misc.Service looking for " + messageService + ", failed");
- failed++;
- }
- if (!sunMiscServiceTest(baseURL, unknownService, false, false, false)) {
- System.out.println("Test: sun.misc.Service looking for " + unknownService + " failed");
- failed++;
- }
-
// Tests using java.util.SerivceLoader
if (!javaUtilServiceLoaderTest(baseURL, messageService, true, false, true)) {
- System.out.println("Test: sun.misc.Service looking for " + messageService + ", failed");
+ System.out.println("Test: ServiceLoader looking for " + messageService + ", failed");
failed++;
}
if (!javaUtilServiceLoaderTest(baseURL, unknownService, false, false, false)) {
- System.out.println("Test: sun.misc.Service looking for " + unknownService + " failed");
+ System.out.println("Test: ServiceLoader looking for " + unknownService + " failed");
failed++;
}
@@ -248,48 +237,6 @@
throw new RuntimeException("Failed: " + failed + " tests");
}
- static boolean sunMiscServiceTest(URL baseURL,
- String serviceClass,
- boolean expectToFind,
- boolean expectbDotJar,
- boolean expectcDotJar) throws IOException {
- debug("----------------------------------");
- debug("Running test with sun.misc.Service looking for " + serviceClass);
- URLClassLoader loader = getLoader(baseURL);
- httpServer.reset();
-
- Class> messageServiceClass = null;
- try {
- messageServiceClass = loader.loadClass(serviceClass);
- } catch (ClassNotFoundException cnfe) {
- System.err.println(cnfe);
- throw new RuntimeException("Error in test: " + cnfe);
- }
-
- Iterator> iterator = sun.misc.Service.providers(messageServiceClass, loader);
- if (expectToFind && !iterator.hasNext()) {
- debug(messageServiceClass + " NOT found.");
- return false;
- }
-
- while (iterator.hasNext()) {
- debug("found " + iterator.next() + " " + messageService);
- }
-
- debug("HttpServer: " + httpServer);
-
- if (!expectbDotJar && httpServer.bDotJar > 0) {
- debug("Unexpeced request sent to the httpserver for b.jar");
- return false;
- }
- if (!expectcDotJar && httpServer.cDotJar > 0) {
- debug("Unexpeced request sent to the httpserver for c.jar");
- return false;
- }
-
- return true;
- }
-
static boolean javaUtilServiceLoaderTest(URL baseURL,
String serviceClass,
boolean expectToFind,
--- old/src/share/classes/sun/misc/Service.java 2014-02-12 10:14:20.268036756 +0000
+++ /dev/null 2013-11-25 15:01:06.400581647 +0000
@@ -1,434 +0,0 @@
-/*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.TreeSet;
-
-
-/**
- * A simple service-provider lookup mechanism. A service is a
- * well-known set of interfaces and (usually abstract) classes. A service
- * provider is a specific implementation of a service. The classes in a
- * provider typically implement the interfaces and subclass the classes defined
- * in the service itself. Service providers may be installed in an
- * implementation of the Java platform in the form of extensions, that is, jar
- * files placed into any of the usual extension directories. Providers may
- * also be made available by adding them to the applet or application class
- * path or by some other platform-specific means.
- *
- *
In this lookup mechanism a service is represented by an interface or an - * abstract class. (A concrete class may be used, but this is not - * recommended.) A provider of a given service contains one or more concrete - * classes that extend this service class with data and code specific to - * the provider. This provider class will typically not be the entire - * provider itself but rather a proxy that contains enough information to - * decide whether the provider is able to satisfy a particular request together - * with code that can create the actual provider on demand. The details of - * provider classes tend to be highly service-specific; no single class or - * interface could possibly unify them, so no such class has been defined. The - * only requirement enforced here is that provider classes must have a - * zero-argument constructor so that they may be instantiated during lookup. - * - *
A service provider identifies itself by placing a provider-configuration - * file in the resource directory META-INF/services. The file's name - * should consist of the fully-qualified name of the abstract service class. - * The file should contain a list of fully-qualified concrete provider-class - * names, one per line. Space and tab characters surrounding each name, as - * well as blank lines, are ignored. The comment character is '#' - * (0x23); on each line all characters following the first comment - * character are ignored. The file must be encoded in UTF-8. - * - *
If a particular concrete provider class is named in more than one - * configuration file, or is named in the same configuration file more than - * once, then the duplicates will be ignored. The configuration file naming a - * particular provider need not be in the same jar file or other distribution - * unit as the provider itself. The provider must be accessible from the same - * class loader that was initially queried to locate the configuration file; - * note that this is not necessarily the class loader that found the file. - * - *
Example: Suppose we have a service class named - * java.io.spi.CharCodec. It has two abstract methods: - * - *
- * public abstract CharEncoder getEncoder(String encodingName); - * public abstract CharDecoder getDecoder(String encodingName); - *- * - * Each method returns an appropriate object or null if it cannot - * translate the given encoding. Typical CharCodec providers will - * support more than one encoding. - * - *
If sun.io.StandardCodec is a provider of the CharCodec - * service then its jar file would contain the file - * META-INF/services/java.io.spi.CharCodec. This file would contain - * the single line: - * - *
- * sun.io.StandardCodec # Standard codecs for the platform - *- * - * To locate an encoder for a given encoding name, the internal I/O code would - * do something like this: - * - *
- * CharEncoder getEncoder(String encodingName) { - * Iterator ps = Service.providers(CharCodec.class); - * while (ps.hasNext()) { - * CharCodec cc = (CharCodec)ps.next(); - * CharEncoder ce = cc.getEncoder(encodingName); - * if (ce != null) - * return ce; - * } - * return null; - * } - *- * - * The provider-lookup mechanism always executes in the security context of the - * caller. Trusted system code should typically invoke the methods in this - * class from within a privileged security context. - * - * @author Mark Reinhold - * @since 1.3 - */ - -public final class Service
This method transforms the name of the given service class into a - * provider-configuration filename as described above and then uses the - * getResources method of the given class loader to find all - * available files with that name. These files are then read and parsed to - * produce a list of provider-class names. The iterator that is returned - * uses the given class loader to lookup and then instantiate each element - * of the list. - * - *
Because it is possible for extensions to be installed into a running - * Java virtual machine, this method may return different results each time - * it is invoked.
- *
- * @param service
- * The service's abstract service class
- *
- * @param loader
- * The class loader to be used to load provider-configuration files
- * and instantiate provider classes, or null if the system
- * class loader (or, failing that the bootstrap class loader) is to
- * be used
- *
- * @return An Iterator that yields provider objects for the given
- * service, in some arbitrary order. The iterator will throw a
- * ServiceConfigurationError if a provider-configuration
- * file violates the specified format or if a provider class cannot
- * be found and instantiated.
- *
- * @throws ServiceConfigurationError
- * If a provider-configuration file violates the specified format
- * or names a provider class that cannot be found and instantiated
- *
- * @see #providers(java.lang.Class)
- * @see #installedProviders(java.lang.Class)
- */
- public static Iterator providers(Class service, ClassLoader loader)
- throws ServiceConfigurationError
- {
- return new LazyIterator(service, loader);
- }
-
-
- /**
- * Locates and incrementally instantiates the available providers of a
- * given service using the context class loader. This convenience method
- * is equivalent to
- *
- *
- * ClassLoader cl = Thread.currentThread().getContextClassLoader();
- * return Service.providers(service, cl);
- *
- *
- * @param service
- * The service's abstract service class
- *
- * @return An Iterator that yields provider objects for the given
- * service, in some arbitrary order. The iterator will throw a
- * ServiceConfigurationError if a provider-configuration
- * file violates the specified format or if a provider class cannot
- * be found and instantiated.
- *
- * @throws ServiceConfigurationError
- * If a provider-configuration file violates the specified format
- * or names a provider class that cannot be found and instantiated
- *
- * @see #providers(java.lang.Class, java.lang.ClassLoader)
- */
- public static Iterator providers(Class service)
- throws ServiceConfigurationError
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return Service.providers(service, cl);
- }
-
-
- /**
- * Locates and incrementally instantiates the available providers of a
- * given service using the extension class loader. This convenience method
- * simply locates the extension class loader, call it
- * extClassLoader, and then does
- *
- *
- * return Service.providers(service, extClassLoader);
- *
- *
- * If the extension class loader cannot be found then the system class
- * loader is used; if there is no system class loader then the bootstrap
- * class loader is used.
- *
- * @param service
- * The service's abstract service class
- *
- * @return An Iterator that yields provider objects for the given
- * service, in some arbitrary order. The iterator will throw a
- * ServiceConfigurationError if a provider-configuration
- * file violates the specified format or if a provider class cannot
- * be found and instantiated.
- *
- * @throws ServiceConfigurationError
- * If a provider-configuration file violates the specified format
- * or names a provider class that cannot be found and instantiated
- *
- * @see #providers(java.lang.Class, java.lang.ClassLoader)
- */
- public static Iterator installedProviders(Class service)
- throws ServiceConfigurationError
- {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- ClassLoader prev = null;
- while (cl != null) {
- prev = cl;
- cl = cl.getParent();
- }
- return Service.providers(service, prev);
- }
-
-}
--- old/src/share/classes/sun/misc/ServiceConfigurationError.java 2014-02-12 10:14:20.760036744 +0000
+++ /dev/null 2013-11-25 15:01:06.400581647 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-
-/**
- * Error thrown when something goes wrong while looking up service providers.
- * In particular, this error will be thrown in the following situations:
- *
- *
- *
- *
- * @author Mark Reinhold
- * @since 1.3
- */
-
-public class ServiceConfigurationError extends Error {
-
- static final long serialVersionUID = 8769866263384244465L;
-
- /**
- * Constructs a new instance with the specified detail string.
- */
- public ServiceConfigurationError(String msg) {
- super(msg);
- }
-
- /**
- * Constructs a new instance that wraps the specified throwable.
- */
- public ServiceConfigurationError(Throwable x) {
- super(x);
- }
-
-}