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