Write the required spring-boot-loader classes to the JAR.
@param loaderJarResourceName the name of the resource containing the loader classes
to be written
@throws IOException if the classes cannot be written
485074
@Override
	public void writeLoaderClasses(String loaderJarResourceName) throws IOException {
		URL loaderJar = getClass().getClassLoader().getResource(loaderJarResourceName);
		try (JarInputStream inputStream = new JarInputStream(
				new BufferedInputStream(loaderJar.openStream()))) {
			JarEntry entry;
			while ((entry = inputStream.getNextJarEntry()) != null) {
				if (entry.getName().endsWith(".class")) {
					writeEntry(new JarArchiveEntry(entry),
							new InputStreamEntryWriter(inputStream, false));
				}
			}
		}
	}
772057
public Runnable writeCatalogJarToFile(String path, String name, CatalogJarWriteMode mode) throws IOException
    {
        File catalogFile = new VoltFile(path, name);
        File catalogTmpFile = new VoltFile(path, name + ".tmp");

        if (mode == CatalogJarWriteMode.CATALOG_UPDATE) {
            // This means a @UpdateCore case, the asynchronous writing of
            // jar file has finished, rename the jar file
            catalogFile.delete();
            catalogTmpFile.renameTo(catalogFile);
            return null;
        }

        if (mode == CatalogJarWriteMode.START_OR_RESTART) {
            // This happens in the beginning of ,
            // when the catalog jar does not yet exist. Though the contents
            // written might be a default one and could be overwritten later
            // by @UAC, @UpdateClasses, etc.
            return m_catalogInfo.m_jarfile.writeToFile(catalogFile);
        }

        if (mode == CatalogJarWriteMode.RECOVER) {
            // we must overwrite the file (the file may have been changed)
            catalogFile.delete();
            if (catalogTmpFile.exists()) {
                // If somehow the catalog temp jar is not cleaned up, then delete it
                catalogTmpFile.delete();
            }

            return m_catalogInfo.m_jarfile.writeToFile(catalogFile);
        }

        VoltDB.crashLocalVoltDB("Unsupported mode to write catalog jar", true, null);
        return null;
    }
749049
public static boolean isJBossRepositoryClassLoader(ClassLoader loader)
   {
      Class<?> clazz = loader.getClass();
      while (!clazz.getName().startsWith("java"))
      {
         if ("org.jboss.mx.loading.RepositoryClassLoader".equals(clazz.getName()))
            return true;
         clazz = clazz.getSuperclass();
      }

      return false;
   }
1300389
public static void load(String originalName, ClassLoader loader) {
        // Adjust expected name to support shading of native libraries.
        String packagePrefix = calculatePackagePrefix().replace('.', '_');
        String name = packagePrefix + originalName;
        List<Throwable> suppressed = new ArrayList<Throwable>();
        try {
            // first try to load from java.library.path
            loadLibrary(loader, name, false);
            return;
        } catch (Throwable ex) {
            suppressed.add(ex);
            logger.debug(
                    "{} cannot be loaded from java.library.path, "
                    + "now trying export to -Dio.netty.native.workdir: {}", name, WORKDIR, ex);
        }

        String libname = System.mapLibraryName(name);
        String path = NATIVE_RESOURCE_HOME + libname;

        InputStream in = null;
        OutputStream out = null;
        File tmpFile = null;
        URL url;
        if (loader == null) {
            url = ClassLoader.getSystemResource(path);
        } else {
            url = loader.getResource(path);
        }
        try {
            if (url == null) {
                if (PlatformDependent.isOsx()) {
                    String fileName = path.endsWith(".jnilib") ? NATIVE_RESOURCE_HOME + "lib" + name + ".dynlib" :
                            NATIVE_RESOURCE_HOME + "lib" + name + ".jnilib";
                    if (loader == null) {
                        url = ClassLoader.getSystemResource(fileName);
                    } else {
                        url = loader.getResource(fileName);
                    }
                    if (url == null) {
                        FileNotFoundException fnf = new FileNotFoundException(fileName);
                        ThrowableUtil.addSuppressedAndClear(fnf, suppressed);
                        throw fnf;
                    }
                } else {
                    FileNotFoundException fnf = new FileNotFoundException(path);
                    ThrowableUtil.addSuppressedAndClear(fnf, suppressed);
                    throw fnf;
                }
            }

            int index = libname.lastIndexOf('.');
            String prefix = libname.substring(0, index);
            String suffix = libname.substring(index, libname.length());

            tmpFile = File.createTempFile(prefix, suffix, WORKDIR);
            in = url.openStream();
            out = new FileOutputStream(tmpFile);

            if (shouldShadedLibraryIdBePatched(packagePrefix)) {
                patchShadedLibraryId(in, out, originalName, name);
            } else {
                byte[] buffer = new byte[8192];
                int length;
                while ((length = in.read(buffer)) > 0) {
                    out.write(buffer, 0, length);
                }
            }

            out.flush();

            // Close the output stream before loading the unpacked library,
            // because otherwise Windows will refuse to load it when it's in use by other process.
            closeQuietly(out);
            out = null;
            loadLibrary(loader, tmpFile.getPath(), true);
        } catch (UnsatisfiedLinkError e) {
            try {
                if (tmpFile != null && tmpFile.isFile() && tmpFile.canRead() &&
                    !NoexecVolumeDetector.canExecuteExecutable(tmpFile)) {
                    // Pass "io.netty.native.workdir" as an argument to allow shading tools to see
                    // the string. Since this is printed out to users to tell them what to do next,
                    // we want the value to be correct even when shading.
                    logger.info("{} exists but cannot be executed even when execute permissions set; " +
                                "check volume for \"noexec\" flag; use -D{}=[path] " +
                                "to set native working directory separately.",
                                tmpFile.getPath(), "io.netty.native.workdir");
                }
            } catch (Throwable t) {
                suppressed.add(t);
                logger.debug("Error checking if {} is on a file store mounted with noexec", tmpFile, t);
            }
            // Re-throw to fail the load
            ThrowableUtil.addSuppressedAndClear(e, suppressed);
            throw e;
        } catch (Exception e) {
            UnsatisfiedLinkError ule = new UnsatisfiedLinkError("could not load a native library: " + name);
            ule.initCause(e);
            ThrowableUtil.addSuppressedAndClear(ule, suppressed);
            throw ule;
        } finally {
            closeQuietly(in);
            closeQuietly(out);
            // After we load the library it is safe to delete the file.
            // We delete the file immediately to free up resources as soon as possible,
            // and if this fails fallback to deleting on JVM exit.
            if (tmpFile != null && (!DELETE_NATIVE_LIB_AFTER_LOADING || !tmpFile.delete())) {
                tmpFile.deleteOnExit();
            }
        }
    }
1263903
private void init(ResourceLoader resourceLoader) throws IOException {
    if (config == null && configs == null) {
      if (typeArgument == null && configArgument == null) {
        throw new IOException("no configuration");
      } else {
        if (typeArgument != null) {
          config = new MtasConfiguration();
          config.attributes.put(MtasConfiguration.CHARFILTER_CONFIGURATION_TYPE,
              typeArgument);
          config.attributes.put(
              MtasConfiguration.CHARFILTER_CONFIGURATION_PREFIX,
              prefixArgument);
          config.attributes.put(
              MtasConfiguration.CHARFILTER_CONFIGURATION_POSTFIX,
              postfixArgument);
        }
        if (configArgument != null) {
          if (resourceLoader != null) {
            try {
              configs = MtasConfiguration.readMtasCharFilterConfigurations(
                  resourceLoader, configArgument);
            } catch (IOException e) {
              throw new IOException(
                  "problem loading configurations from " + configArgument, e);
            }
          }
        }
      }
    }
  }
28477
public static synchronized File getJarResources()
    {
        if (!loader.isPresent())
        {
            throw new LionEngineException(JAR_LOADER_ERROR);
        }

        final Media media = Medias.create(Constant.EMPTY_STRING);
        final String path = media.getFile().getPath().replace(File.separator, Constant.SLASH);
        final String prefix = loader.get().getPackage().getName().replace(Constant.DOT, Constant.SLASH);
        final int jarSeparatorIndex = path.indexOf(prefix);
        final String jar = path.substring(0, jarSeparatorIndex);

        return new File(jar);
    }
868965
public void setResourceAdapterClassLoader(ResourceAdapterClassLoader v)
   {
      if (trace)
         log.tracef("%s: setResourceAdapterClassLoader(%s)", Integer.toHexString(System.identityHashCode(this)), v);

      resourceAdapterClassLoader = v;
   }
507641
public void addClassLoader(final ClassLoader classLoader) {
        if (this.addedClassLoaders == null) {
            this.addedClassLoaders = new ArrayList<>();
        }
        if (classLoader != null) {
            this.addedClassLoaders.add(classLoader);
        }
    }
151319
private void addClassToDoFromJars() {
        if (!Utils.isNullOrEmpty(settings.getJarFiles())) {
            try {
                String[] files = settings.getJarFiles().split(";");
                for (String path : files) {
                    File file = new File(path);
                    if (!file.isFile()) {
                        String jarPath = classLoader.getJar(path);
                        if (jarPath == null) {
                            getFileManager().logInfo("can't find " + path);
                        }
                        file = new File(new URI(jarPath));
                    }
                    getFileManager().logInfo("searching classes to wrappe in " + file.getAbsolutePath());
                    JarFile jf = new JarFile(file);
                    Enumeration<JarEntry> entries = jf.entries();
                    while (entries.hasMoreElements()) {
                        String clName = entries.nextElement().getName();
                        if (clName.endsWith(".class")) {
                            Class<?> clazz = classLoader.loadClass(clName.split("\\.")[0].replace('/', '.'));
                            if (clazz.isAnnotationPresent(Java4Cpp.class)) {
                                addClassToDo(clazz);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException("Failed to load jar " + e.getMessage());
            }
        }
    }
1099564
public static synchronized void loadLibrary(File jar) throws NoAvailableBackendException {
        try {
            /*We are using reflection here to circumvent encapsulation; addURL is not public*/
            java.net.URLClassLoader loader = (java.net.URLClassLoader) ClassLoader.getSystemClassLoader();
            java.net.URL url = jar.toURI().toURL();
            /*Disallow if already loaded*/
            for (java.net.URL it : java.util.Arrays.asList(loader.getURLs())) {
                if (it.equals(url)) {
                    return;
                }
            }
            java.lang.reflect.Method method =
                            java.net.URLClassLoader.class.getDeclaredMethod("addURL", new Class[] {java.net.URL.class});
            method.setAccessible(true); /*promote the method to public access*/
            method.invoke(loader, new Object[] {url});
        } catch (final java.lang.NoSuchMethodException | java.lang.IllegalAccessException
                        | java.net.MalformedURLException | java.lang.reflect.InvocationTargetException e) {
            throw new NoAvailableBackendException(e);
        }
    }
229884
public static JarClassLoader loadJar(File jarFile) {
		final JarClassLoader loader = new JarClassLoader();
		loader.addJar(jarFile);
		return loader;
	}
904885
private void addJobJarToClassPath(String localJarFile, StringBuffer classPath) {
    File jobCacheDir = new File
      (new Path(localJarFile).getParent().toString());
    File[] libs = new File(jobCacheDir, "lib").listFiles();
    String sep = System.getProperty("path.separator");

    if (libs != null) {
      for (int i = 0; i < libs.length; i++) {
        classPath.append(sep); // add libs from jar to classpath
        classPath.append(libs[i]);
      }
    }
    classPath.append(sep);
    classPath.append(new File(jobCacheDir, "classes"));
    classPath.append(sep);
    classPath.append(jobCacheDir);
  }
429528
@Override
    @Trivial
    public void addClassLoader(ClassLoader classLoader) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "addClassLoader - " + classLoader);
        }

        if (classLoader instanceof ContainerClassLoader) {
            synchronized (classLoaders) {
                classLoaders.add((ContainerClassLoader) classLoader);
            }
        } else {
            throw new IllegalArgumentException("classLoader is not a ContainerClassLoader");
        }
    }
1196995
@Override
    protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
        synchronized (getClassLoadingLock(name)) {
            Class<?> result = null;

            if (name == null || name.length() == 0)
                return null;

            result = findLoadedClass(name);
            if (result == null) {
                if (name.regionMatches(0, BootstrapChildFirstJarClassloader.KERNEL_BOOT_CLASS_PREFIX, 0,
                                       BootstrapChildFirstJarClassloader.KERNEL_BOOT_PREFIX_LENGTH)) {
                    result = super.loadClass(name, resolve);
                } else {
                    try {
                        // Try to load the class from this classpath
                        result = findClass(name);
                    } catch (ClassNotFoundException cnfe) {
                        result = super.loadClass(name, resolve);
                    }
                }
            }

            return result;
        }
    }
285214
private void addBootJars(List<File> jarFiles, List<URL> urlList) {
        for (File jarFile : jarFiles) {
            try {
                urlList.add(jarFile.toURI().toURL());
            } catch (MalformedURLException e) {
                // Unlikely: we're making URLs for files we know exist
            }
        }
    }
1205273
public void classLoaderInit(DynamicClassLoader loader)
  {
    EnvLoaderListener listener = _listenerRef.get();
    
    if (listener != null)
      listener.classLoaderInit(loader);
  }
670453
public void extractResources() throws IOException {
        if (!cacheDir.isDirectory()) {
            if (!cacheDir.mkdirs()) {
                //debug("Failed to create cachedJar dir for dependent resources: " + cachedir);
            }
        }
        if (null != resourcesList) {
            //debug("jar manifest lists resources: " + resourcesList + " for file: " + pluginJar);

            extractJarContents(resourcesList, cacheDir);
            for (final String s : resourcesList) {
                File libFile = new File(cacheDir, s);
                libFile.deleteOnExit();
            }
        } else {
            //debug("using resources dir: " + resDir + " for file: " + pluginJar);
            ZipUtil.extractZip(zipFile.getAbsolutePath(), cacheDir, resourcesBasedir, resourcesBasedir);
        }
    }