ClassInfo (Groovy 2.5.0)
Date: 2018-05-27

org.codehaus.groovy.reflection

## Class ClassInfo

- java.lang.Object
- - org.codehaus.groovy.reflection.ClassInfo

- All Implemented Interfaces:
    Finalizable

      public class ClassInfo
      extends java.lang.Object
      implements Finalizable

  Handle for all information we want to keep about the class

  This class handles caching internally and its 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 Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `ClassInfo.ClassInfoAction`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `hash`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clearModifiedExpandos()`
    `void` | `finalizeReference()`
    `static int` | `fullSize()`
    `static java.util.Collection<ClassInfo>` | `getAllClassInfo()`
    `ClassLoaderForClassArtifacts` | `getArtifactClassLoader()`
    `CachedClass` | `getCachedClass()`
    `static ClassInfo` | `getClassInfo(java.lang.Class cls)`
    `MetaClass` | `getMetaClass()` Returns the `MetaClass` for the `Class` associated with this `ClassInfo`.
    `MetaClass` | `getMetaClass(java.lang.Object obj)`
    `MetaClass` | `getMetaClassForClass()`
    `ExpandoMetaClass` | `getModifiedExpando()`
    `MetaClass` | `getPerInstanceMetaClass(java.lang.Object obj)`
    `MetaClass` | `getStrongMetaClass()`
    `java.lang.Class<?>` | `getTheClass()` Returns the `Class` associated with this `ClassInfo`.
    `int` | `getVersion()`
    `MetaClass` | `getWeakMetaClass()`
    `boolean` | `hasPerInstanceMetaClasses()`
    `void` | `incVersion()`
    `void` | `lock()`
    `static void` | `onAllClassInfo(ClassInfo.ClassInfoAction action)`
    `static void` | `remove(java.lang.Class<?> cls)` Removes a `ClassInfo` from the cache.
    `void` | `setPerInstanceMetaClass(java.lang.Object obj, MetaClass metaClass)`
    `void` | `setStrongMetaClass(MetaClass answer)`
    `void` | `setWeakMetaClass(MetaClass answer)`
    `static int` | `size()`
    `void` | `unlock()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### hash

          public final int hash

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getVersion

          public int getVersion()

    - #### incVersion

          public void incVersion()

    - #### getModifiedExpando

          public ExpandoMetaClass getModifiedExpando()

    - #### clearModifiedExpandos

          public static void clearModifiedExpandos()

    - #### getTheClass

          public final java.lang.Class<?> getTheClass()

      Returns the `Class` associated with this `ClassInfo`.

      This method can return `null` if the `Class` is no longer reachable through any strong or soft references. A non-null return value indicates that this `ClassInfo` is valid.

      Returns:
        the `Class` associated with this `ClassInfo`, else `null`

    - #### getCachedClass

          public CachedClass getCachedClass()

    - #### getArtifactClassLoader

          public ClassLoaderForClassArtifacts getArtifactClassLoader()

    - #### getClassInfo

          public static ClassInfo getClassInfo(java.lang.Class cls)

    - #### remove

          public static void remove(java.lang.Class<?> cls)

      Removes a `ClassInfo` from 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 the `ClassInfo` associated 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

          public static java.util.Collection<ClassInfo> getAllClassInfo()

    - #### onAllClassInfo

          public static void onAllClassInfo(ClassInfo.ClassInfoAction action)

    - #### getStrongMetaClass

          public MetaClass getStrongMetaClass()

    - #### setStrongMetaClass

          public void setStrongMetaClass(MetaClass answer)

    - #### getWeakMetaClass

          public MetaClass getWeakMetaClass()

    - #### setWeakMetaClass

          public void setWeakMetaClass(MetaClass answer)

    - #### getMetaClassForClass

          public MetaClass getMetaClassForClass()

    - #### getMetaClass

          public final MetaClass getMetaClass()

      Returns the `MetaClass` for the `Class` associated with this `ClassInfo`. If no `MetaClass` exists one will be created.

      It is not safe to call this method without a `Class` associated with this `ClassInfo`. It is advisable to aways retrieve a ClassInfo instance from the cache by using the static factory method `getClassInfo(Class)` to ensure the referenced Class is strongly reachable.

      Returns:
        a `MetaClass` instance

    - #### getMetaClass

          public MetaClass getMetaClass(java.lang.Object obj)

    - #### size

          public static int size()

    - #### fullSize

          public static int fullSize()

    - #### lock

          public void lock()

    - #### unlock

          public void unlock()

    - #### getPerInstanceMetaClass

          public MetaClass getPerInstanceMetaClass(java.lang.Object obj)

    - #### setPerInstanceMetaClass

          public void setPerInstanceMetaClass(java.lang.Object obj,
                                              MetaClass metaClass)

    - #### hasPerInstanceMetaClasses

          public boolean hasPerInstanceMetaClasses()

    - #### finalizeReference

          public void finalizeReference()

      Specified by:
        `finalizeReference` in interface `Finalizable`