Class GeneratedClassLoader

java.lang.Object
java.lang.ClassLoader
io.micronaut.sourcegen.bytecode.tck.GeneratedClassLoader

public final class GeneratedClassLoader extends ClassLoader
Loads classes a backend wrote, by binary name, so that they can refer to each other and to the classes of the tests that wrote them. Shared by the TCK and the tests of every backend.
Since:
2.3
  • Constructor Details

    • GeneratedClassLoader

      public GeneratedClassLoader(Map<String,byte[]> classes)
      A loader whose parent is the loader of the TCK, and so of the tests.
      Parameters:
      classes - The class file bytes by binary name
    • GeneratedClassLoader

      public GeneratedClassLoader(ClassLoader parent, Map<String,byte[]> classes)
      A loader with the given parent.
      Parameters:
      parent - The parent loader
      classes - The class file bytes by binary name
  • Method Details

    • defineDirectly

      public static Class<?> defineDirectly(String name, byte[] bytes)
      Defines one class at once in a loader of its own, without asking the parent loader for a class of the same name first.
      Parameters:
      name - The binary name of the class
      bytes - The class file bytes
      Returns:
      The defined class
    • findClass

      protected Class<?> findClass(String name) throws ClassNotFoundException
      Overrides:
      findClass in class ClassLoader
      Throws:
      ClassNotFoundException