RFR: 8042906: Remove use of reflection in ORB

Paul Sandoz paul.sandoz at oracle.com
Tue May 13 10:22:05 UTC 2014


On May 13, 2014, at 11:34 AM, Seán Coffey <sean.coffey at oracle.com> wrote:

> thanks for the comments. I hit a build issue when introducing some lambda syntax to the corba repo : https://bugs.openjdk.java.net/browse/JDK-8042932
> 
> That's fixed now and I can continue with the corba push. I've cleaned up the ORB class to make better use of generics and the diamond operator. Removed some unused package imports also. Taken Daniel's suggestion to use ConcurrentHashMap on board (and removed the sync block)
> 
> http://cr.openjdk.java.net/~coffeys/webrev.8042906.v2/webrev/
> 

There are also some compute-if-absent patterns that might be applicable:

 503     public LogWrapperBase getLogWrapper(String logDomain,
 504         String exceptionGroup, LogWrapperFactory factory)
 505     {
 506         StringPair key = new StringPair(logDomain, exceptionGroup);
 507 
 508         LogWrapperBase logWrapper = wrapperMap.get(key);
 509         if (logWrapper == null) {
 510             logWrapper = factory.create(getLogger(logDomain));
 511             wrapperMap.put(key, logWrapper);
 512         }
 513 
 514         return logWrapper;
 515     }
 516 
 517     /** get the log wrapper class (its type is dependent on the exceptionGroup) for the
 518      * given log domain and exception group in this ORB instance.
 519      */
 520     public static LogWrapperBase staticGetLogWrapper(String logDomain,
 521         String exceptionGroup, LogWrapperFactory factory)
 522     {
 523         StringPair key = new StringPair(logDomain, exceptionGroup);
 524 
 525         LogWrapperBase logWrapper = staticWrapperMap.get(key);
 526         if (logWrapper == null) {
 527             logWrapper = factory.create( staticGetLogger(logDomain));
 528             staticWrapperMap.put(key, logWrapper);
 529         }
 530 
 531         return logWrapper;
 532     }

  return wrapperMap.computeIfAbsent(new StringPair(...), 
      x -> factory.create(....));

Paul.



More information about the core-libs-dev mailing list