changeset 1181:e61d93fc8ed1

6818072: Load Ductus using Class.forName if exist instead of using the service loader Summary: First attempt Class.forName to load Ductus class before using service loader Reviewed-by: flar, prr
author mchung
date Tue, 14 Apr 2009 17:43:45 -0700
parents e3b4eb55a696
children d609ae2faac2
files src/share/classes/sun/java2d/pipe/RenderingEngine.java
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Wed Apr 08 15:40:56 2009 -0700
+++ b/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Tue Apr 14 17:43:45 2009 -0700
@@ -95,6 +95,11 @@
      * <pre>
      *     java -Dsun.java2d.renderer=&lt;classname&gt;
      * </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.
@@ -115,9 +120,21 @@
         reImpl = (RenderingEngine)
             AccessController.doPrivileged(new PrivilegedAction() {
                 public Object run() {
+                    final String ductusREClass = "sun.dc.DuctusRenderingEngine";
                     String reClass =
-                        System.getProperty("sun.java2d.renderer",
-                                           "sun.dc.DuctusRenderingEngine");
+                        System.getProperty("sun.java2d.renderer", ductusREClass);
+                    if (reClass.equals(ductusREClass)) {
+                        try {
+                            Class cls = Class.forName(ductusREClass);
+                            return cls.newInstance();
+                        } catch (ClassNotFoundException x) {
+                            // not found
+                        } catch (IllegalAccessException x) {
+                            // should not reach here
+                        } catch (InstantiationException x) {
+                            // should not reach here
+                        }
+                    }
 
                     ServiceLoader<RenderingEngine> reLoader =
                         ServiceLoader.loadInstalled(RenderingEngine.class);