8038876: Remove use of ServiceLoader in finding class implementing sun.java2d.cmm.CMMServiceProvider
authorprr
Mon, 12 May 2014 09:32:23 -0700
changeset 24559 58573b0353be
parent 24558 045a3c5d8252
child 24560 4f5e79f02d71
8038876: Remove use of ServiceLoader in finding class implementing sun.java2d.cmm.CMMServiceProvider Reviewed-by: bae, mchung
jdk/make/CopyIntoClasses.gmk
jdk/make/profile-rtjar-includes.txt
jdk/src/share/classes/sun/java2d/cmm/CMSManager.java
jdk/src/share/classes/sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider
--- a/jdk/make/CopyIntoClasses.gmk	Mon May 12 18:21:15 2014 +0400
+++ b/jdk/make/CopyIntoClasses.gmk	Mon May 12 09:32:23 2014 -0700
@@ -111,18 +111,8 @@
   ALL_META-INF_DIRS := $(ALL_META-INF_DIRS_share)
 endif
 
-ifndef OPENJDK
-  ALL_META-INF_DIRS += $(JDK_TOPDIR)/src/closed/share/classes/sun/java2d/cmm/kcms/META-INF
-endif
-
 SRC_SERVICES_FILES := $(wildcard $(addsuffix /services/*, $(ALL_META-INF_DIRS)))
 
-ifdef OPENJDK
-  SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/kcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
-else
-  SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
-endif
-
 # The number of services files are relatively few. If the increase in numbers, then
 # we have to use ListPathsSafelyNow here.
 # Change $(JDK_TOPDIR)/src/.../META-INF/services/yyyy into $(JDK_OUTPUTDIR)/classes/META-INF/services/yyyy
--- a/jdk/make/profile-rtjar-includes.txt	Mon May 12 18:21:15 2014 +0400
+++ b/jdk/make/profile-rtjar-includes.txt	Mon May 12 09:32:23 2014 -0700
@@ -241,5 +241,4 @@
     META-INF/services/javax.sound.sampled.spi.AudioFileReader \
     META-INF/services/javax.sound.sampled.spi.AudioFileWriter \
     META-INF/services/javax.sound.sampled.spi.FormatConversionProvider \
-    META-INF/services/javax.sound.sampled.spi.MixerProvider \
-    META-INF/services/sun.java2d.cmm.PCMM
+    META-INF/services/javax.sound.sampled.spi.MixerProvider
--- a/jdk/src/share/classes/sun/java2d/cmm/CMSManager.java	Mon May 12 18:21:15 2014 +0400
+++ b/jdk/src/share/classes/sun/java2d/cmm/CMSManager.java	Mon May 12 09:32:23 2014 -0700
@@ -34,7 +34,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import sun.security.action.GetPropertyAction;
-import java.util.ServiceLoader;
 
 public class CMSManager {
     public static ColorSpace GRAYspace;       // These two fields allow access
@@ -52,35 +51,28 @@
             return cmmImpl;
         }
 
-        CMMServiceProvider spi = AccessController.doPrivileged(
-                new PrivilegedAction<CMMServiceProvider>() {
-                    public CMMServiceProvider run() {
-                        String cmmClass = System.getProperty(
-                            "sun.java2d.cmm", "sun.java2d.cmm.lcms.LcmsServiceProvider");
-
-                    ServiceLoader<CMMServiceProvider> cmmLoader
-                    = ServiceLoader.loadInstalled(CMMServiceProvider.class);
-
-                CMMServiceProvider spi = null;
+        GetPropertyAction gpa = new GetPropertyAction("sun.java2d.cmm");
+        String cmmProviderClass = AccessController.doPrivileged(gpa);
+        CMMServiceProvider provider = null;
+        if (cmmProviderClass != null) {
+            try {
+                Class<?> cls = Class.forName(cmmProviderClass);
+                provider = (CMMServiceProvider)cls.newInstance();
+            } catch (ReflectiveOperationException e) {
+            }
+        }
+        if (provider == null) {
+            provider = new sun.java2d.cmm.lcms.LcmsServiceProvider();
+        }
 
-                for (CMMServiceProvider cmm : cmmLoader) {
-                    spi = cmm;
-                    if (cmm.getClass().getName().equals(cmmClass)) {
-                        break;
-                    }
-                }
-                return spi;
-            }
-        });
-
-        cmmImpl = spi.getColorManagementModule();
+        cmmImpl = provider.getColorManagementModule();
 
         if (cmmImpl == null) {
             throw new CMMException("Cannot initialize Color Management System."+
                                    "No CM module found");
         }
 
-        GetPropertyAction gpa = new GetPropertyAction("sun.java2d.cmm.trace");
+        gpa = new GetPropertyAction("sun.java2d.cmm.trace");
         String cmmTrace = AccessController.doPrivileged(gpa);
         if (cmmTrace != null) {
             cmmImpl = new CMMTracer(cmmImpl);
--- a/jdk/src/share/classes/sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider	Mon May 12 18:21:15 2014 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-#  Little CMS color management module
-sun.java2d.cmm.lcms.LcmsServiceProvider