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 uses "io.github.classgraph" for boring and encapsulate the needed API calls.
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
    • getUnusedPackageNames

      public Set<String> getUnusedPackageNames()
    • 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
    • getUsedClassspath

      public SortedSet<URI> getUsedClassspath()
      Scans the classpath to return a set of the used classpath.
      Returns:
      used classpath (sorted)
    • findClass

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