/** * Find the classloader or classloaders most likely to represent the order that classloaders are used to resolve * classes in the current context. Uses the technique described by <a href= * "http://www.javaworld.com/article/2077344/core-java/find-a-way-out-of-the-classloader-maze.html">Vladimir * Roubtsov</a>. * * <p> * Generally this will return exactly one ClassLoader, but if it returns more than one, the classloaders are * listed in the order they should be called in until one of them is able to load the named class. If you can * call only one ClassLoader, use the first element of the list. * * <p> * If you have overridden the ClassLoader(s), then the override ClassLoader(s) will be returned instead. * * <p> * Deprecated, since classloaders may need to be generated dynamically for loading classes from Spring-Boot jars * and similar (#209). * * @return A list of one or more ClassLoaders, out of the system ClassLoader, the current classloader, or the * context classloader (or the override ClassLoaders, if ClassLoaders have been overridden). */ @Deprecated public ClassLoader[] findBestClassLoader() { return new ClassLoaderAndModuleFinder(getScanSpec(), log).getClassLoaders(); }
final ClassLoaderAndModuleFinder classLoaderAndModuleFinder = classpathFinder .getClassLoaderAndModuleFinder(); final ClassLoader[] classLoaderOrder = classLoaderAndModuleFinder.getClassLoaders(); final List<RelativePath> rawClasspathEltOrder = new ArrayList<>(); final List<ModuleRef> systemModules = classLoaderAndModuleFinder.getSystemModuleRefs(); if (systemModules != null) { for (final ModuleRef systemModule : systemModules) { final List<ModuleRef> nonSystemModules = classLoaderAndModuleFinder.getNonSystemModuleRefs(); if (nonSystemModules != null) { for (final ModuleRef nonSystemModule : nonSystemModules) {
final ClassLoader[] envClassLoaderOrder = new ClassLoaderAndModuleFinder(deserialized.scanSpec, /* log = */ null).getClassLoaders(); final Map<String, ClassInfo> classNameToClassInfo = new HashMap<>(); for (final ClassInfo ci : deserialized.allClassInfo) {
classLoaderAndModuleFinder = new ClassLoaderAndModuleFinder(scanSpec, classpathFinderLog); final ClassLoader[] classLoaders = classLoaderAndModuleFinder.getClassLoaders(); if (scanSpec.overrideClasspath != null) {