[OpenJDK 2D-Dev] Fwd: Re: Small patch for multi-catch :)

Ulf Zibis Ulf.Zibis at gmx.de
Sat Jul 23 20:19:55 UTC 2011


Hi,

couldn't you use ReflectiveOperationException instead?


Additionally you could better profit from generics:

     public static synchronized RenderingEngine getInstance() {
         if (reImpl == null) {
             reImpl = AccessController.doPrivileged(
                     new PrivilegedAction<RenderingEngine>() {
                 public RenderingEngine run() {
                     String reClass = System.getProperty("sun.java2d.renderer");
                     if ("sun.dc.DuctusRenderingEngine".equals(reClass)) {
                         try {
                             return (RenderingEngine)Class.forName(reClass).newInstance();
                         } catch (ReflectiveOperationException ignored) {
                         } // not found
                     }

                     for (RenderingEngine re : ServiceLoader.loadInstalled(
                             RenderingEngine.class)) {
                         if (re.getClass().getName().equals(reClass)) {
                             return re;
                         }
                     }
                     return null;
                 }
             });
             if (reImpl == null) {
                 throw new InternalError("No RenderingEngine module found");
             }
             if(AccessController.doPrivileged(new GetPropertyAction(
                     "sun.java2d.renderer.trace")) != null) {
                 reImpl = new Tracer(reImpl);
             }
         }

         return reImpl;
     }

And again more simple just use (no need for try...catch):

                 public RenderingEngine run() {
                     String reClass = System.getProperty("sun.java2d.renderer");
                     if ("sun.dc.DuctusRenderingEngine".equals(reClass)) {
                         return new sun.dc.DuctusRenderingEngine();
                     }
                     for (RenderingEngine re : ServiceLoader.loadInstalled(
                             RenderingEngine.class)) {
                         if (re.getClass().getName().equals(reClass)) {
                             return re;
                         }
                     }
                     return null;
                 }

-Ulf



Am 23.07.2011 18:16, schrieb Phil Race:
> Apparently bugs.openjdk.java.net hasn't heard of JDK 8
>
> -phil.
>
> -------- Original Message --------
> Subject:     Re: [OpenJDK 2D-Dev] Small patch for multi-catch :)
> Date:     Sat, 23 Jul 2011 13:35:27 +0200
> From:     Mario Torre <neugens.limasoftware at gmail.com>
> To:     Phil Race <philip.race at oracle.com>
> CC:     2d-dev at openjdk.java.net
>
>
>
> 2011/7/23 Phil Race<philip.race at oracle.com>:
>>  Looks OK .. you'll need to generate yourself a bug id.
>>
>>  -phil.
>>
>
> Hello Phil,
>
> Thanks for the quick answer. I filed a new bug report, the ID is 100195:
>
> https://bugs.openjdk.java.net/show_bug.cgi?id=100195
>
> I could not set the target release as JDK8, though.
>
> Cheers,
> Mario



More information about the 2d-dev mailing list