Class Loader

    • Constructor Detail

      • Loader

        public Loader()
        Default constructor. Parent class loader is the system class loader.
      • Loader

        public Loader​(ClassLoader parentLoader)
        Constructor with explicit parent class loader.
        Parameters:
        parentLoader - parent class loader
    • Method Detail

      • createClass

        public static Class<?> createClass​(Class<?> contextClass,
                                           Generator generator,
                                           Object... nameSuffix)
                                    throws ClassNotFoundException

        Convenience method to generate and load a class.

        Creates a Loader with the ClassLoader of a context class as parent loader and passes the Generator to it. The name of the generated class is 'Generated' plus the given nameSuffixes, each separated by an underline character. If a nameSuffix is of type Class, the class name is used as nameSuffix. Dots in a nameSuffix are replaced by underlines.

        Parameters:
        contextClass - context class
        generator - generator
        nameSuffix - optional name suffixes to build the name of the generated class
        Returns:
        generated class
        Throws:
        ClassNotFoundException - when the context class could not be found
      • setGenerator

        public void setGenerator​(Generator generator)
        Sets the generator.
        Parameters:
        generator - the generator