Class DMClassLoader

java.lang.Object
java.lang.ClassLoader
org.bzdev.lang.DMClassLoader

@Deprecated public class DMClassLoader extends ClassLoader
Deprecated.
This class has been deprecated due to a change in OpenJDK. For about 2 decades, this class would work with the standard Java class loader. With the introduction of modules, the class loader became much more restrictive. Test cases that used to work failed because this class could no longer execute the register method on behalf of the user.

The original documentation was:

With the default class loader, each local helper class has to be loaded explicitly, typically by calling the helper's register() static method from the corresponding class implementing a dynamic method. DMClassLoader eliminates the need to do that by calling the register() methods automatically.

To use this class loader as the system class loader, set the system property java.lang.class.loader to org.bzdev.lang.DMClassLoader when the JVM is started. One may also set the context class loader for each thread.

This class loader delegates class loading in the same way as java.lang.ClassLoader but adds the dynamic-method initialization described above. It also verifies that a class implementing dynamic methods and its local helper have the same code source and are in the same package.

If run when the default security manager is installed, the runtime permission getProtectionDomain must be granted. This is used for verifying that dynamic-method annotations are in the same protection domain as this class loader, and that a class and its helper class are similarly in the same protection domain in addition to being in the same package.

Class loader supporting dynamic methods.
See Also:
  • Constructor Details

    • DMClassLoader

      public DMClassLoader()
      Deprecated.
      Constructor.
    • DMClassLoader

      public DMClassLoader(ClassLoader parent)
      Deprecated.
      Constructor.
      Parameters:
      parent - the parent class loader
  • Method Details