Class ClassInfo
- All Implemented Interfaces:
- Finalizable
 This class handles caching internally and it's advisable to not store
 references directly to objects of this class.  The static factory method
 getClassInfo(Class) should be used to retrieve an instance
 from the cache.  Internally the Class associated with a ClassInfo
 instance is kept as WeakReference, so it not safe to reference
 and instance without the Class being either strongly or softly reachable.
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidvoidstatic intfullSize()static Collection<ClassInfo>static ClassInfogetClassInfo(Class cls) final MetaClassReturns theMetaClassfor theClassassociated with thisClassInfo.getMetaClass(Object obj) final Class<?>Returns theClassassociated with thisClassInfo.intbooleanvoidvoidlock()static voidstatic voidRemoves aClassInfofrom the cache.voidsetPerInstanceMetaClass(Object obj, MetaClass metaClass) voidsetStrongMetaClass(MetaClass answer) voidsetWeakMetaClass(MetaClass answer) static intsize()voidunlock()
- 
Field Details- 
hashpublic final int hash- See Also:
 
 
- 
- 
Method Details- 
getVersionpublic int getVersion()
- 
incVersionpublic void incVersion()
- 
getModifiedExpando
- 
clearModifiedExpandospublic static void clearModifiedExpandos()
- 
getTheClassReturns theClassassociated with thisClassInfo.This method can return nullif theClassis no longer reachable through any strong or soft references. A non-null return value indicates that thisClassInfois valid.- Returns:
- the Classassociated with thisClassInfo, elsenull
 
- 
getCachedClass
- 
getArtifactClassLoader
- 
getClassInfo
- 
removeRemoves aClassInfofrom the cache. This is useful in cases where the Class is parsed from a script, such as when using GroovyClassLoader#parseClass, and is executed for its result but the Class is not retained or cached. Removing theClassInfoassociated with the Class will make the Class and its ClassLoader eligible for garbage collection sooner that it would otherwise.- Parameters:
- cls- the Class associated with the ClassInfo to remove from cache
 
- 
getAllClassInfo
- 
onAllClassInfo
- 
getStrongMetaClass
- 
setStrongMetaClass
- 
getWeakMetaClass
- 
setWeakMetaClass
- 
getMetaClassForClass
- 
getMetaClassReturns theMetaClassfor theClassassociated with thisClassInfo. If noMetaClassexists one will be created.It is not safe to call this method without a Classassociated with thisClassInfo. It is advisable to always retrieve a ClassInfo instance from the cache by using the static factory methodgetClassInfo(Class)to ensure the referenced Class is strongly reachable.- Returns:
- a MetaClassinstance
 
- 
getMetaClass
- 
sizepublic static int size()
- 
fullSizepublic static int fullSize()
- 
lockpublic void lock()
- 
unlockpublic void unlock()
- 
getPerInstanceMetaClass
- 
setPerInstanceMetaClass
- 
hasPerInstanceMetaClassespublic boolean hasPerInstanceMetaClasses()
- 
finalizeReferencepublic void finalizeReference()- Specified by:
- finalizeReferencein interface- Finalizable
 
 
-