Class QuarkusClassLoader
java.lang.Object
java.lang.ClassLoader
io.quarkus.bootstrap.classloading.QuarkusClassLoader
- All Implemented Interfaces:
Closeable,AutoCloseable
The ClassLoader used for non production Quarkus applications (i.e. dev and test mode).
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseTask(Runnable task) static QuarkusClassLoader.Builderbuilder(String name, ClassLoader parent, boolean parentFirst) voidclose()protected Class<?>This method is needed to make packages work correctly on JDK9+, as it will be called to load the package-info class.protected URLfindResource(String name) protected Enumeration<URL>findResources(String name) static List<ClassPathElement>getElements(String resourceName, boolean onlyFromCurrentClassLoader) getElementsWithResource(String name, boolean localOnly) getName()getResource(String unsanitisedName) getResourceAsStream(String unsanitisedName) getResources(String unsanitisedName) getResources(String unsanitisedName, boolean parentAlreadyFoundResources) static booleanisApplicationClass(String className) Indicates if a given class is considered an application class.static booleanisClassPresentAtRuntime(String className) Indicates if a given class is present at runtime.booleanisClosed()static booleanisResourcePresentAtRuntime(String resourcePath) Indicates if a given resource is present at runtime.Class<?>protected Class<?>parent()voidtoString()Class<?>visibleDefineClass(String name, byte[] b, int off, int len) static voidvisitRuntimeResources(String resourceName, Consumer<PathVisit> visitor) Visits every found runtime resource with a given name.Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getPackage, getPackages, getParent, getPlatformClassLoader, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
META_INF_SERVICES
- See Also:
-
-
Method Details
-
visitRuntimeResources
Visits every found runtime resource with a given name. If a resource is not found, the visitor will simply not be called.IMPORTANT: this method works only when the current class loader is an instance of
QuarkusClassLoader, otherwise it throws an error with the corresponding message.- Parameters:
resourceName- runtime resource name to visitvisitor- runtime resource visitor
-
getElements
public static List<ClassPathElement> getElements(String resourceName, boolean onlyFromCurrentClassLoader) -
isClassPresentAtRuntime
Indicates if a given class is present at runtime.- Parameters:
className- the name of the class.
-
isApplicationClass
Indicates if a given class is considered an application class. -
isResourcePresentAtRuntime
Indicates if a given resource is present at runtime. Can also be used to check if a class is present as a class is just a regular resource.- Parameters:
resourcePath- the path of the resource, for instancepath/to/my-resources.propertiesfor a properties file ormy/package/MyClass.classfor a class.
-
builder
public static QuarkusClassLoader.Builder builder(String name, ClassLoader parent, boolean parentFirst) -
reset
-
getResources
- Overrides:
getResourcesin classClassLoader- Throws:
IOException
-
getResources
public Enumeration<URL> getResources(String unsanitisedName, boolean parentAlreadyFoundResources) throws IOException - Throws:
IOException
-
getResource
- Overrides:
getResourcein classClassLoader
-
getResourceAsStream
- Overrides:
getResourceAsStreamin classClassLoader
-
findClass
This method is needed to make packages work correctly on JDK9+, as it will be called to load the package-info class.- Overrides:
findClassin classClassLoader- Parameters:
moduleName-name-- Returns:
-
findResource
- Overrides:
findResourcein classClassLoader
-
findResources
- Overrides:
findResourcesin classClassLoader- Throws:
IOException
-
loadClass
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
loadClass
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
getElementsWithResource
-
getElementsWithResource
-
getReloadableClassNames
-
visibleDefineClass
- Throws:
ClassFormatError
-
addCloseTask
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isClosed
public boolean isClosed() -
toString
-
parent
-
getName
- Overrides:
getNamein classClassLoader
-