changeset 9991:1a6c78863ead

8038876: Remove use of ServiceLoader in finding class implementing sun.java2d.cmm.CMMServiceProvider Reviewed-by: bae, mchung
author prr
date Mon, 12 May 2014 09:32:23 -0700
parents e343eef24517
children a0fcf95f8143
files make/CopyIntoClasses.gmk make/profile-rtjar-includes.txt src/share/classes/sun/java2d/cmm/CMSManager.java src/share/classes/sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider
diffstat 4 files changed, 16 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/make/CopyIntoClasses.gmk	Mon May 12 18:21:15 2014 +0400
+++ b/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/make/profile-rtjar-includes.txt	Mon May 12 18:21:15 2014 +0400
+++ b/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/src/share/classes/sun/java2d/cmm/CMSManager.java	Mon May 12 18:21:15 2014 +0400
+++ b/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");
+        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();
+        }
 
-                    ServiceLoader<CMMServiceProvider> cmmLoader
-                    = ServiceLoader.loadInstalled(CMMServiceProvider.class);
-
-                CMMServiceProvider spi = null;
-
-                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/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