8038875: Remove use of ServiceLoader in finding class implementing sun.java2d.pipe. RenderingEngine
Reviewed-by: flar, mchung
--- a/jdk/make/CopyIntoClasses.gmk Thu May 08 18:37:34 2014 +0400
+++ b/jdk/make/CopyIntoClasses.gmk Thu May 08 15:17:02 2014 -0700
@@ -118,10 +118,8 @@
SRC_SERVICES_FILES := $(wildcard $(addsuffix /services/*, $(ALL_META-INF_DIRS)))
ifdef OPENJDK
- SRC_SERVICES_FILES := $(filter-out %sun/dc/META-INF/services/sun.java2d.pipe.RenderingEngine, $(SRC_SERVICES_FILES))
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/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine, $(SRC_SERVICES_FILES))
SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
endif
--- a/jdk/make/profile-rtjar-includes.txt Thu May 08 18:37:34 2014 +0400
+++ b/jdk/make/profile-rtjar-includes.txt Thu May 08 15:17:02 2014 -0700
@@ -242,5 +242,4 @@
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/sun.java2d.pipe.RenderingEngine
+ META-INF/services/sun.java2d.cmm.PCMM
--- a/jdk/src/share/classes/sun/dc/META-INF/services/sun.java2d.pipe.RenderingEngine Thu May 08 18:37:34 2014 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Ductus Rendering Engine module
-sun.dc.DuctusRenderingEngine
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Thu May 08 18:37:34 2014 +0400
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Thu May 08 15:17:02 2014 -0700
@@ -32,7 +32,6 @@
import java.security.PrivilegedAction;
import java.security.AccessController;
-import java.util.ServiceLoader;
import sun.security.action.GetPropertyAction;
import sun.awt.geom.PathConsumer2D;
@@ -97,12 +96,9 @@
* </pre>
*
* If no specific {@code RenderingEngine} is specified on the command
- * or Ductus renderer is specified, it will attempt loading the
- * sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath;
- * if not found, use the ServiceLoader.
- * If no specific {@code RenderingEngine} is specified on the command
- * line then the last one returned by enumerating all subclasses of
- * {@code RenderingEngine} known to the ServiceLoader is used.
+ * or Ductus renderer is specified, it will first attempt loading the
+ * sun.dc.DuctusRenderingEngine class using Class.forName, if that
+ * is not found, then it will look for Pisces.
* <p>
* Runtime tracing of the actions of the {@code RenderingEngine}
* can be enabled by specifying the runtime flag:
@@ -117,42 +113,30 @@
return reImpl;
}
- reImpl =
- AccessController.doPrivileged(new PrivilegedAction<RenderingEngine>() {
- public RenderingEngine run() {
- final String ductusREClass = "sun.dc.DuctusRenderingEngine";
- String reClass =
- System.getProperty("sun.java2d.renderer", ductusREClass);
- if (reClass.equals(ductusREClass)) {
- try {
- Class<?> cls = Class.forName(ductusREClass);
- return (RenderingEngine) cls.newInstance();
- } catch (ReflectiveOperationException ignored) {
- // not found
- }
- }
-
- ServiceLoader<RenderingEngine> reLoader =
- ServiceLoader.loadInstalled(RenderingEngine.class);
-
- RenderingEngine service = null;
-
- for (RenderingEngine re : reLoader) {
- service = re;
- if (re.getClass().getName().equals(reClass)) {
- break;
- }
- }
- return service;
- }
- });
+ /* Look first for ductus or an app-override renderer,
+ * if not specified or present, then look for pisces.
+ */
+ final String ductusREClass = "sun.dc.DuctusRenderingEngine";
+ final String piscesREClass = "sun.java2d.pisces.PiscesRenderingEngine";
+ GetPropertyAction gpa =
+ new GetPropertyAction("sun.java2d.renderer", ductusREClass);
+ String reClass = AccessController.doPrivileged(gpa);
+ try {
+ Class<?> cls = Class.forName(reClass);
+ reImpl = (RenderingEngine) cls.newInstance();
+ } catch (ReflectiveOperationException ignored0) {
+ try {
+ Class<?> cls = Class.forName(piscesREClass);
+ reImpl = (RenderingEngine) cls.newInstance();
+ } catch (ReflectiveOperationException ignored1) {
+ }
+ }
if (reImpl == null) {
throw new InternalError("No RenderingEngine module found");
}
- GetPropertyAction gpa =
- new GetPropertyAction("sun.java2d.renderer.trace");
+ gpa = new GetPropertyAction("sun.java2d.renderer.trace");
String reTrace = AccessController.doPrivileged(gpa);
if (reTrace != null) {
reImpl = new Tracer(reImpl);
--- a/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine Thu May 08 18:37:34 2014 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-# Pisces Rendering Engine module
-sun.java2d.pisces.PiscesRenderingEngine
--- a/jdk/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine Thu May 08 18:37:34 2014 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-# Jules Rendering Engine module
-sun.java2d.jules.JulesRenderingEngine
-
-# Pisces Rendering Engine module
-sun.java2d.pisces.PiscesRenderingEngine