## org.codehaus.groovy.runtime.metaclass
Class ReflectorLoader

Reflector creation helper. This class is used to define the Refloctor classes. For each ClassLoader such a loader will be created by MetaClass. Special about this loader is, that it knows the classes form the Groovy Runtime. The Reflector class is resolved in different ways: During the definition of a class Reflector will resolve to the Reflector class of the runtime, even if there is another Reflector class in the parent loader. After the new class is defined Reflector will resolve like other Groovy classes. This loader is able to resolve all Groovy classes even if the parent does not know them, but the parent serves first (Reflector during a class defintion is different).

author:
  Jochen Theodorou

version:
  $Revision: 8280 $

Field Summary
`String` | `REFLECTOR`
`ClassLoader` | `delegatationLoader`
`boolean` | `inDefine`
`Map` | `loadedClasses`

Constructor Summary
`ReflectorLoader(ClassLoader parent)` creates a RelfectorLoader.

Method Summary
`Class` | `defineClass(String name, def bytecode, ProtectionDomain domain)` helper method to define Reflector classes.
`Class` | `findClass(String name)` Tries to find a Groovy class.
`Class` | `getLoadedClass(String name)` try to load one of the defined Reflector classes by name.
`static String` | `getReflectorName(Class theClass)`
`Class` | `loadClass(String name, boolean resolve)` Loads a class per name.

Constructor Detail

### ReflectorLoader

    public ReflectorLoader(ClassLoader parent)

  creates a RelfectorLoader.
  param:
    parent the parent loader. This should never be null!

Method Detail

### defineClass

    public Class defineClass(String name, def bytecode, ProtectionDomain domain)

  helper method to define Reflector classes.
  param:
    name of the Reflector
  param:
    bytecode the bytecode
  param:
    domain the protection domain
  return:
    the generated class

### findClass

    Class findClass(String name)

  Tries to find a Groovy class.
  return:
    the class if found
  throws:
    ClassNotFoundException if not found

### getLoadedClass

    public Class getLoadedClass(String name)

  try to load one of the defined Reflector classes by name.
  param:
    name of the Reflector class
  return:
    the Reflector class if defined else null.

### getReflectorName

    public static String getReflectorName(Class theClass)

### loadClass

    Class loadClass(String name, boolean resolve)

  Loads a class per name. Unlike a normal loadClass this version behaves different during a class definition. In that case it checks if the class we want to load is Reflector and returns class if the check is successful. If it is not during a class definition it just calls the super class version of loadClass.
  param:
    name of the class to load
  param:
    resolve is true if the class should be resolved
  see:
    Reflector
  see:
    ClassLoader#loadClass(String, boolean)