2018-09-22 17:22:39 +03:00
|
|
|
package ru.gravit.utils;
|
2018-09-17 10:07:32 +03:00
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URLClassLoader;
|
|
|
|
|
2018-09-22 17:22:39 +03:00
|
|
|
import ru.gravit.launcher.LauncherAPI;
|
2018-09-17 10:07:32 +03:00
|
|
|
|
2018-09-22 17:22:39 +03:00
|
|
|
public class PublicURLClassLoader extends URLClassLoader {
|
2018-09-22 17:33:00 +03:00
|
|
|
@LauncherAPI
|
2018-09-17 10:07:32 +03:00
|
|
|
public static ClassLoader systemclassloader = ClassLoader.getSystemClassLoader();
|
2018-09-22 17:33:00 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
@LauncherAPI
|
2018-09-22 17:33:00 +03:00
|
|
|
public static ClassLoader getSystemClassLoader() {
|
2018-09-17 10:07:32 +03:00
|
|
|
return systemclassloader;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a new URLClassLoader for the specified URLs using the
|
|
|
|
* default delegation parent {@code ClassLoader}. The URLs will
|
|
|
|
* be searched in the order specified for classes and resources after
|
|
|
|
* first searching in the parent class loader. Any URL that ends with
|
|
|
|
* a '/' is assumed to refer to a directory. Otherwise, the URL is
|
|
|
|
* assumed to refer to a JAR file which will be downloaded and opened
|
|
|
|
* as needed.
|
|
|
|
*
|
|
|
|
* <p>If there is a security manager, this method first
|
|
|
|
* calls the security manager's {@code checkCreateClassLoader} method
|
|
|
|
* to ensure creation of a class loader is allowed.
|
|
|
|
*
|
|
|
|
* @param urls the URLs from which to load classes and resources
|
|
|
|
* @throws SecurityException if a security manager exists and its
|
|
|
|
* {@code checkCreateClassLoader} method doesn't allow
|
|
|
|
* creation of a class loader.
|
|
|
|
* @throws NullPointerException if {@code urls} is {@code null}.
|
|
|
|
* @see SecurityManager#checkCreateClassLoader
|
|
|
|
*/
|
2018-09-22 17:22:39 +03:00
|
|
|
public PublicURLClassLoader(URL[] urls) {
|
2018-09-17 10:07:32 +03:00
|
|
|
super(urls);
|
|
|
|
}
|
2018-09-22 17:33:00 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
/**
|
|
|
|
* Constructs a new URLClassLoader for the given URLs. The URLs will be
|
|
|
|
* searched in the order specified for classes and resources after first
|
|
|
|
* searching in the specified parent class loader. Any {@code jar:}
|
|
|
|
* scheme URL is assumed to refer to a JAR file. Any {@code file:} scheme
|
|
|
|
* URL that ends with a '/' is assumed to refer to a directory. Otherwise,
|
|
|
|
* the URL is assumed to refer to a JAR file which will be downloaded and
|
|
|
|
* opened as needed.
|
|
|
|
*
|
|
|
|
* <p>If there is a security manager, this method first
|
|
|
|
* calls the security manager's {@code checkCreateClassLoader} method
|
|
|
|
* to ensure creation of a class loader is allowed.
|
|
|
|
*
|
|
|
|
* @param urls the URLs from which to load classes and resources
|
|
|
|
* @param parent the parent class loader for delegation
|
|
|
|
* @throws SecurityException if a security manager exists and its
|
|
|
|
* {@code checkCreateClassLoader} method doesn't allow
|
|
|
|
* creation of a class loader.
|
|
|
|
* @throws NullPointerException if {@code urls} is {@code null}.
|
|
|
|
* @see SecurityManager#checkCreateClassLoader
|
|
|
|
*/
|
2018-09-22 17:22:39 +03:00
|
|
|
public PublicURLClassLoader(URL[] urls, ClassLoader parent) {
|
2018-09-17 10:07:32 +03:00
|
|
|
super(urls, parent);
|
|
|
|
}
|
2018-09-22 17:33:00 +03:00
|
|
|
|
2018-09-17 10:07:32 +03:00
|
|
|
@Override
|
|
|
|
public void addURL(URL url) {
|
|
|
|
super.addURL(url);
|
|
|
|
}
|
|
|
|
}
|