6818072: Load Ductus using Class.forName if exist instead of using the service loader
First attempt Class.forName to load Ductus class before using service loader Reviewed-by: flar, prr
This commit is contained in:
parent
e19d0ec5d0
commit
15dd62fcba
@ -95,6 +95,11 @@ public abstract class RenderingEngine {
|
|||||||
* <pre>
|
* <pre>
|
||||||
* java -Dsun.java2d.renderer=<classname>
|
* java -Dsun.java2d.renderer=<classname>
|
||||||
* </pre>
|
* </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
|
* If no specific {@code RenderingEngine} is specified on the command
|
||||||
* line then the last one returned by enumerating all subclasses of
|
* line then the last one returned by enumerating all subclasses of
|
||||||
* {@code RenderingEngine} known to the ServiceLoader is used.
|
* {@code RenderingEngine} known to the ServiceLoader is used.
|
||||||
@ -115,9 +120,21 @@ public abstract class RenderingEngine {
|
|||||||
reImpl = (RenderingEngine)
|
reImpl = (RenderingEngine)
|
||||||
AccessController.doPrivileged(new PrivilegedAction() {
|
AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
public Object run() {
|
public Object run() {
|
||||||
|
final String ductusREClass = "sun.dc.DuctusRenderingEngine";
|
||||||
String reClass =
|
String reClass =
|
||||||
System.getProperty("sun.java2d.renderer",
|
System.getProperty("sun.java2d.renderer", ductusREClass);
|
||||||
"sun.dc.DuctusRenderingEngine");
|
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<RenderingEngine> reLoader =
|
||||||
ServiceLoader.loadInstalled(RenderingEngine.class);
|
ServiceLoader.loadInstalled(RenderingEngine.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user