本文整理汇总了Java中jdk.internal.loader.URLClassPath类的典型用法代码示例。如果您正苦于以下问题:Java URLClassPath类的具体用法?Java URLClassPath怎么用?Java URLClassPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URLClassPath类属于jdk.internal.loader包,在下文中一共展示了URLClassPath类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: URLClassLoader
import jdk.internal.loader.URLClassPath; //导入依赖的package包/类
URLClassLoader(String name, URL[] urls, ClassLoader parent,
AccessControlContext acc) {
super(name, parent);
// this is to make the stack depth consistent with 1.1
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkCreateClassLoader();
}
this.acc = acc;
this.ucp = new URLClassPath(urls, acc);
}
示例2: findResource
import jdk.internal.loader.URLClassPath; //导入依赖的package包/类
/**
* Finds the resource with the specified name on the URL search path.
*
* @param name the name of the resource
* @return a {@code URL} for the resource, or {@code null}
* if the resource could not be found, or if the loader is closed.
*/
public URL findResource(final String name) {
/*
* The same restriction to finding classes applies to resources
*/
URL url = AccessController.doPrivileged(
new PrivilegedAction<>() {
public URL run() {
return ucp.findResource(name, true);
}
}, acc);
return url != null ? URLClassPath.checkURL(url) : null;
}
示例3: findResource
import jdk.internal.loader.URLClassPath; //导入依赖的package包/类
/**
* Finds a resource in a module, returning {@code null} if the resource
* is not found.
*/
private static Resource findResource(String module, String name) {
if (reader != null) {
URL url = toJrtURL(module, name);
ImageLocation location = reader.findLocation(module, name);
if (location != null && URLClassPath.checkURL(url) != null) {
return new Resource() {
@Override
public String getName() {
return name;
}
@Override
public URL getURL() {
return url;
}
@Override
public URL getCodeSourceURL() {
return toJrtURL(module);
}
@Override
public InputStream getInputStream() throws IOException {
byte[] resource = reader.getResource(location);
return new ByteArrayInputStream(resource);
}
@Override
public int getContentLength() {
long size = location.getUncompressedSize();
return (size > Integer.MAX_VALUE) ? -1 : (int) size;
}
};
}
}
return null;
}
示例4: URLClassLoader
import jdk.internal.loader.URLClassPath; //导入依赖的package包/类
URLClassLoader(URL[] urls, ClassLoader parent,
AccessControlContext acc) {
super(parent);
// this is to make the stack depth consistent with 1.1
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkCreateClassLoader();
}
ucp = new URLClassPath(urls);
this.acc = acc;
}
示例5: getURLClassPath
import jdk.internal.loader.URLClassPath; //导入依赖的package包/类
public URLClassPath getURLClassPath(URLClassLoader u) {
return u.ucp;
}
示例6: getURLClassPath
import jdk.internal.loader.URLClassPath; //导入依赖的package包/类
/**
* return the URLClassPath belonging to the given loader
*/
URLClassPath getURLClassPath (URLClassLoader u);