Package org.codehaus.groovy.runtime.metaclass

# Class ReflectorLoader

java.lang.Object
java.lang.ClassLoader
org.codehaus.groovy.runtime.metaclass.ReflectorLoader

@Deprecated(since="6.0.0", forRemoval=true) public class ReflectorLoader extends ClassLoader
Deprecated, for removal: This API element is subject to removal in a future version.
No production callers remain; kept only for binary compatibility.
Reflector creation helper historically used to define `Reflector` subclasses.

Deprecated since 6.0.0. Production MetaClass / call-site paths no longer construct or use this loader; the only remaining references are tests. Prefer modern reflective / method-handle dispatch. Retained for binary compatibility only; will be removed in a future major release.

Special about this loader is that it knows the classes from the Groovy runtime. During class definition `Reflector` resolves to the runtime's `Reflector` even if a different one exists in the parent loader.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ReflectorLoader(ClassLoader parent)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Creates a new ReflectorLoader with the specified parent class loader.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Class<?>`
  `defineClass(String name, byte[] bytecode, ProtectionDomain domain)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Defines a Reflector class via `ClassLoader.defineClass(byte[], int, int)` and caches it under `name`.
  `protected Class<?>`
  `findClass(String name)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Tries to find a Groovy class.
  `Class<?>`
  `getLoadedClass(String name)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Retrieves a previously defined Reflector class by name from the cache.
  `protected Class<?>`
  `loadClass(String name, boolean resolve)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Loads a class per name.

  ### Methods inherited from class java.lang.ClassLoader

  `clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners`

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

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

- ## Constructor Details

  - ### ReflectorLoader

    public ReflectorLoader(ClassLoader parent)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a new ReflectorLoader with the specified parent class loader.
    Parameters:
      `parent` - the parent class loader (should never be `null`)

- ## Method Details

  - ### findClass

    protected Class<?> findClass(String name) throws ClassNotFoundException
    Deprecated, for removal: This API element is subject to removal in a future version.
    Tries to find a Groovy class. Uses the delegation loader to load classes when available.
    Overrides:
      `findClass` in class `ClassLoader`
    Parameters:
      `name` - the fully qualified name of the class to find
    Returns:
      the class if found
    Throws:
      `ClassNotFoundException` - if the class cannot be found

  - ### loadClass

    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
    Deprecated, for removal: This API element is subject to removal in a future version.
    Loads a class per name. Unlike a normal `loadClass` this version behaves differently during a class definition. In that case it checks if the class we want to load is `Reflector` and returns that class if the check is successful. If it is not during a class definition it just calls the super class version of `loadClass`.
    Overrides:
      `loadClass` in class `ClassLoader`
    Parameters:
      `name` - of the class to load
      `resolve` - is `true` if the class should be resolved
    Throws:
      `ClassNotFoundException`
    See Also:
      - `Reflector`
      - `ClassLoader.loadClass(String, boolean)`

  - ### defineClass

    public Class<?> defineClass(String name, byte[] bytecode, ProtectionDomain domain)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Defines a Reflector class via `ClassLoader.defineClass(byte[], int, int)` and caches it under `name`.

    Sets `inDefine` during definition so `Reflector` resolves to the runtime class.

    Parameters:
      `name` - cache key and binary name of the Reflector class
      `bytecode` - the bytecode of the Reflector class
      `domain` - the protection domain
    Returns:
      the newly defined class

  - ### getLoadedClass

    public Class<?> getLoadedClass(String name)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Retrieves a previously defined Reflector class by name from the cache.
    Parameters:
      `name` - the fully qualified name of the Reflector class
    Returns:
      the Reflector class if it has been defined, or `null` otherwise