java.net.URLClassLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-mt-jre-emulation Show documentation
Show all versions of gwt-mt-jre-emulation Show documentation
Additional jre emulation classes for gwt and j2cl.
package java.net;
/**
* This stripped down URLClassLoader class is simply here to give us cross-platform support for code
* that might need a valid classloader.
*
*
* If support is ever needed, we can implement a generator which will set the URLs of any
* URLClassLoader to the jars and source paths used to compile GWT.
*
*
* @author "James X. Nelson ([email protected])"
*
*/
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class URLClassLoader extends ClassLoader {
private URL[] urls;
public URLClassLoader(final URL[] urls, final ClassLoader parent) {
super(parent);
this.urls = urls;
}
public URLClassLoader(final URL[] urls) {
this(urls, ClassLoader.getSystemClassLoader());
}
// Included here so attempts at reflection succeed
protected void addURL(final URL url) {
final URL[] newUrls = new URL[this.urls.length + 1];
System.arraycopy(url, 0, newUrls, 0, this.urls.length);
newUrls[this.urls.length] = url;
this.urls = newUrls;
}
public URL[] getURLs() {
return this.urls;
}
public static URLClassLoader newInstance(final URL[] urls, final ClassLoader parent) {
return new URLClassLoader(urls, parent);
}
public static URLClassLoader newInstance(final URL[] urls) {
return new URLClassLoader(urls);
}
}