Class BoringClassLoader

java.lang.Object
java.lang.ClassLoader
clazzfish.monitor.internal.BoringClassLoader

public class BoringClassLoader extends ClassLoader
Die Klasse BoringClassLoader is used for boring into some internals of a ClassLoader. It used "io.github.classgraph" for boring and encapsulate the needed API calls.

Sincd 2.8 the dependency to "io.github.classgraph" was removed to reduce the dependencies.

Since:
2.0 (15.02.23)
Author:
oboehm
  • Field Details

  • Method Details

    • of

      public static BoringClassLoader of(ClassLoader classLoader)
      Creates a BoringClassLoader from the given classLoder. If the given classLoader itself is a BoringClassLoader it will be returned. In this case no new BoringClassLoader is created.
      Parameters:
      classLoader - the parent ClassLoader
      Returns:
      a new BoringClassLoader or the classLoader itself
    • getAllPackageNames

      public Set<String> getAllPackageNames()
      Gets all package names. Also the packages which are not yet loaded.
      Returns:
      set of all package names
    • getLoadedClasses

      public Set<Class<?>> getLoadedClasses()
      Gets the laoded classes which normally is stored in the classes field of the parent classloader. But since Java 11 it is no longer possible to access this field by reflection. So now the loaded packages are scanned for the classes which might be loaded.

      The actual implementation uses the DiagnosticCommand MBean as described in Stackoverflow. Other tries with e.g. with the ClassPath class from Googles Guava were not successful.

      Returns:
      all loaded classes
    • findClass

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