Class BoringClassLoader
java.lang.Object
java.lang.ClassLoader
clazzfish.monitor.internal.BoringClassLoader
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected Class
<?> Gets all package names.Gets the laoded classes which normally is stored in the classes field of the parent classloader.Scans the classpath to return a set of the used classpath.static BoringClassLoader
of
(ClassLoader classLoader) Creates aBoringClassLoader
from the given classLoder.Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
DEFAULT_CLOADER
-
SYSTEM_CLOADER
-
-
Method Details
-
of
Creates aBoringClassLoader
from the given classLoder. If the given classLoader itself is aBoringClassLoader
it will be returned. In this case no newBoringClassLoader
is created.- Parameters:
classLoader
- the parentClassLoader
- Returns:
- a new
BoringClassLoader
or the classLoader itself
-
getAllPackageNames
-
getUnusedPackageNames
-
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
-
findClass
- Overrides:
findClass
in classClassLoader
- Throws:
ClassNotFoundException
-