RFR (S) CR 8016236: Class.getGenericInterfaces performance improvement

Peter Levart peter.levart at gmail.com
Mon Jun 10 22:18:05 UTC 2013


On 06/10/2013 10:57 PM, Peter Levart wrote:
> I don't think 3 fields are needed (genericSignatureResolved, 
> genericSignature & genericInfo). I think one boolean flag (say : 
> genericInfoPresent) and genericInfo is all that is needed. If there 
> was a singleton ClassRepository NONE instance, then even the boolean 
> flag wouldn't be needed.

Hi Aleksey,

Here's what I meant by above (no genericSignature caching is needed and 
no additional fields):


     private static class LazyHolder {
         static final ClassRepository NULL_CLASS_REPOSITORY = 
ClassRepository.make("Ljava/lang/Object;", null);
     }

     // accessor for generic info repository
     private ClassRepository getGenericInfo() {
         ClassRepository genericInfo = this.genericInfo;
         // lazily initialize repository if necessary
         if (genericInfo == null) {
             String signature = getGenericSignature();
             // create and cache generic info repository
             this.genericInfo = genericInfo = (signature == null)
             ? LazyHolder.NULL_CLASS_REPOSITORY
             : ClassRepository.make(signature, getFactory());
         }
         //return cached repository
         return genericInfo == LazyHolder.NULL_CLASS_REPOSITORY
                ? null
                : genericInfo;
     }



Regards, Peter




More information about the core-libs-dev mailing list