Package io.quarkus.bootstrap.runner
Class AotRunnerClassLoader
java.lang.Object
java.lang.ClassLoader
io.quarkus.bootstrap.runner.AotRunnerClassLoader
A ClassLoader that behaves similarly to the RunnerClassLoader for resources
but delegates all class loading to the JDK application class loader.
The idea is that it lets us optimize the resource case, while still benefiting from AOT.
Our hope is that we will be able to use a fully custom ClassLoader with Project Leyden at some point but we are not there
yet.
Key characteristics:
- All class loading is delegated to the parent
- Resource lookups are intercepted for the service files and otherwise delegated to the parent
- For some selected directories, we have a full index of the content so that we can avoid negative lookups in the parent
Note that not all ServiceLoader calls will hit this ClassLoader as some low levels one are directly hitting
the ClassLoader used to load the classes, thus circumventing the optimizations we have in this ClassLoader.
It is an expected behavior though, and will be vastly improved once we can use a custom ClassLoader with Leyden.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected 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) findResources(String name) Finds all resources with the given name.getResource(String name) getResources(String name) Gets all resources with the given name.inthashCode()Class<?> Class<?> Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResourceAsStream, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Method Details
-
loadClass
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
loadClass
- Overrides:
loadClassin classClassLoader- Throws:
ClassNotFoundException
-
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
-
getResource
- Overrides:
getResourcein classClassLoader
-
findResource
- Overrides:
findResourcein classClassLoader
-
getResources
Gets all resources with the given name. This is the method called by ServiceLoader and other resource loading mechanisms. If the resource is cached, returns ONLY the cached version without jar scanning. This is the key optimization - service files and config files are pre-cached, so ServiceLoader and config loading don't need to scan jars.- Overrides:
getResourcesin classClassLoader- Parameters:
name- the resource name- Returns:
- an enumeration of URLs for the resources
- Throws:
IOException- if I/O errors occur
-
findResources
Finds all resources with the given name. If the resource is cached, returns ONLY the cached version without jar scanning.- Overrides:
findResourcesin classClassLoader- Parameters:
name- the resource name- Returns:
- an enumeration of URLs for the resources
- Throws:
IOException- if I/O errors occur
-
equals
-
hashCode
public int hashCode()
-