Java 类sun.misc.Resource 实例源码

项目:intellij-ce-playground    文件:InstrumentationClassFinder.java   
private InputStream getClassBytesStream(String internalName) throws IOException {
  InputStream is = null;
  // first look into platformCp
  final String resourceName = internalName + CLASS_RESOURCE_EXTENSION;
  Resource resource = myPlatformClasspath.getResource(resourceName, false);
  if (resource != null) {
    is = new ByteArrayInputStream(resource.getBytes());
  }
  // second look into memory and classspath
  if (is == null) {
    is = lookupClassBeforeClasspath(internalName);
  }

  if (is == null) {
    resource = myClasspath.getResource(resourceName, false);
    if (resource != null) {
      is = new ByteArrayInputStream(resource.getBytes());
    }
  }

  if (is == null) {
    is = lookupClassAfterClasspath(internalName);
  }
  return is;
}
项目:intellij-ce-playground    文件:InstrumentationClassFinder.java   
public InputStream getResourceAsStream(String resourceName) throws IOException {
  InputStream is = null;

  Resource resource = myPlatformClasspath.getResource(resourceName, false);
  if (resource != null) {
    is = new ByteArrayInputStream(resource.getBytes());
  }

  if (is == null) {
    resource = myClasspath.getResource(resourceName, false);
    if (resource != null) {
      is = new ByteArrayInputStream(resource.getBytes());
    }
  }

  return is;
}
项目:intellij-ce-playground    文件:InstrumentationClassFinder.java   
public Resource getResource(final String name, boolean check) {
  URL url = null;
  File file = null;

  try {
    url = new URL(getBaseURL(), name);
    if (!url.getFile().startsWith(getBaseURL().getFile())) {
      return null;
    }

    file = new File(myRootDir, name.replace('/', File.separatorChar));
    if (!check || file.exists()) {     // check means we load or process resource so we check its existence via old way
      return new FileResource(name, url, file, !check);
    }
  }
  catch (Exception exception) {
    if (!check && file != null && file.exists()) {
      try {   // we can not open the file if it is directory, Resource still can be created
        return new FileResource(name, url, file, false);
      }
      catch (IOException ex) {
      }
    }
  }
  return null;
}
项目:VarJ    文件:URLClassLoader.java   
/**
    * Finds and loads the class with the specified name from the URL search
    * path. Any URLs referring to JAR files are loaded and opened as needed
    * until the class is found.
    *
    * @param name the name of the class
    * @return the resulting class
    * @exception ClassNotFoundException if the class could not be found
    */
   protected Class<?> findClass(final String name)
 throws ClassNotFoundException
   {
try {
    return (Class)
    AccessController.doPrivileged(new PrivilegedExceptionAction() {
        public Object run() throws ClassNotFoundException {
        String path = name.replace('.', '/').concat(".class");
        Resource res = ucp.getResource(path, false);
        if (res != null) {
            try {
            return defineClass(name, res);
            } catch (IOException e) {
            throw new ClassNotFoundException(name, e);
            }
        } else {
            throw new ClassNotFoundException(name);
        }
        }
    }, acc);
} catch (java.security.PrivilegedActionException pae) {
    throw (ClassNotFoundException) pae.getException();
}
   }
项目:petablox    文件:HijackingClassLoader.java   
protected Class findClass(final String name) throws ClassNotFoundException {
    try {
        return (Class) AccessController.doPrivileged(
            new PrivilegedExceptionAction() {
                public Object run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        if (TRACE) System.out.println("Hijacked! " + res);
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
}
项目:mdep    文件:ParentLastURLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @throws ClassNotFoundException if the class could not be found,
 *                                or if the loader is closed.
 * @throws NullPointerException   if {@code name} is {@code null}.
 */
@Override
@SneakyThrows(ReflectiveOperationException.class)
protected Class<?> findClass(String name)
        throws ClassNotFoundException {
    String path = name.replace('.', '/') + ".class";

    Field ucpField = URLClassLoader.class.getDeclaredField("ucp");
    ucpField.setAccessible(true);
    Resource res = ((URLClassPath) ucpField.get(this)).getResource(path, false);
    if (res != null) {
        try {
            return defineClass(name, res);
        } catch (IOException e) {
            throw new ClassNotFoundException(name, e);
        }
    } else {
        throw new ClassNotFoundException(name);
    }
}
项目:jdk-1.7-annotated    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 */
protected Class<?> findClass(final String name)
     throws ClassNotFoundException
{
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class>() {
                public Class run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
}
项目:jdk7-jdk    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 */
protected Class<?> findClass(final String name)
     throws ClassNotFoundException
{
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class>() {
                public Class run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
}
项目:openjdk-source-code-learn    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 */
protected Class<?> findClass(final String name)
     throws ClassNotFoundException
{
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class>() {
                public Class run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
}
项目:OLD-OpenJDK8    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
     throws ClassNotFoundException
{
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
}
项目:tools-idea    文件:InstrumentationClassFinder.java   
private InputStream getClassBytesStream(String internalName) throws IOException {
  InputStream is = null;
  // first look into platformCp
  final String resourceName = internalName + CLASS_RESOURCE_EXTENSION;
  Resource resource = myPlatformClasspath.getResource(resourceName, false);
  if (resource != null) {
    is = new ByteArrayInputStream(resource.getBytes());
  }
  // second look into memory and classspath
  if (is == null) {
    is = lookupClassBeforeClasspath(internalName);
  }

  if (is == null) {
    resource = myClasspath.getResource(resourceName, false);
    if (resource != null) {
      is = new ByteArrayInputStream(resource.getBytes());
    }
  }

  if (is == null) {
    is = lookupClassAfterClasspath(internalName);
  }
  return is;
}
项目:tools-idea    文件:InstrumentationClassFinder.java   
public InputStream getResourceAsStream(String resourceName) throws IOException {
  InputStream is = null;

  Resource resource = myPlatformClasspath.getResource(resourceName, false);
  if (resource != null) {
    is = new ByteArrayInputStream(resource.getBytes());
  }

  if (is == null) {
    resource = myClasspath.getResource(resourceName, false);
    if (resource != null) {
      is = new ByteArrayInputStream(resource.getBytes());
    }
  }

  return is;
}
项目:tools-idea    文件:InstrumentationClassFinder.java   
public Resource getResource(final String name, boolean check) {
  URL url = null;
  File file = null;

  try {
    url = new URL(getBaseURL(), name);
    if (!url.getFile().startsWith(getBaseURL().getFile())) {
      return null;
    }

    file = new File(myRootDir, name.replace('/', File.separatorChar));
    if (!check || file.exists()) {     // check means we load or process resource so we check its existence via old way
      return new FileResource(name, url, file, !check);
    }
  }
  catch (Exception exception) {
    if (!check && file != null && file.exists()) {
      try {   // we can not open the file if it is directory, Resource still can be created
        return new FileResource(name, url, file, false);
      }
      catch (IOException ex) {
      }
    }
  }
  return null;
}
项目:tools-idea    文件:UrlClassLoader.java   
private Class defineClass(String name, Resource res) throws IOException {
  int i = name.lastIndexOf('.');
  if (i != -1) {
    String pkgname = name.substring(0, i);
    // Check if package already loaded.
    Package pkg = getPackage(pkgname);
    if (pkg == null) {
      try {
        definePackage(pkgname, null, null, null, null, null, null, null);
      }
      catch (IllegalArgumentException e) {
        // do nothing, package already defined by some other thread
      }
    }
  }

  byte[] b = res.getBytes();
  return _defineClass(name, b);
}
项目:openjdk-jdk7u-jdk    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 */
protected Class<?> findClass(final String name)
     throws ClassNotFoundException
{
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class>() {
                public Class run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
}
项目:openjdk-icedtea7    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 */
protected Class<?> findClass(final String name)
     throws ClassNotFoundException
{
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class>() {
                public Class run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
}
项目:java-sandbox    文件:SandboxLoader.java   
private SandboxLoader doGetSubLoaderByClassContext(String clazz) {
    String path = clazz.replace('.', '/').concat(".class");
    for(Entry<URLClassPath, SandboxLoader> e : subLoaderByJar.entrySet()){
        Resource res = e.getKey().getResource(path, false);
        if (res != null)
            return e.getValue();
    }

    SandboxLoader subLoader = subLoaderCache.get(clazz);
    if(null != subLoader)
        return subLoader;
    for(String prefix : subLoaderPrefixCache.keySet())
        if(clazz.startsWith(prefix))
            return subLoaderPrefixCache.get(prefix);


    return null;
}
项目:java-sandbox    文件:SandboxLoader.java   
private boolean bypassClazz(String name) {
    if(null != enhancer && enhancer.isLoadClassWithApplicationLoader(name))
        return true;

    if(classesToLoadWithParent.contains(name))
        return ! prohibitBypass(name);
    for(String bp : classesByPrefixToLoadWithParent)
        if(name.startsWith(bp))
            return ! prohibitBypass(name);

    /* check if it comes from an available jar */
    if(! name.startsWith("java.") && null != bypassUcp){
        String path = name.replace('.', '/').concat(".class");

        Resource res = bypassUcp.getResource(path, false);
        if (res != null) 
            return ! prohibitBypass(name);
    }

    return false;
}
项目:lightmare    文件:EjbClassLoader.java   
/**
 * Replica of parent {@link URLClassLoader} and {@link ClassLoader} class
 * method for other method
 *
 * @return {@link URL}
 */
private static Enumeration<URL> getBootstrapResources(String name) throws IOException {

    Enumeration<URL> urls;

    // Enumeration to iterate over
    final Enumeration<Resource> resources = getBootstrapsResources(name);
    urls = new Enumeration<URL>() {

        public URL nextElement() {
            return (resources.nextElement()).getURL();
        }

        public boolean hasMoreElements() {
            return resources.hasMoreElements();
        }
    };

    return urls;
}
项目:OpenJSharp    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:OpenJSharp    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
    throws ClassNotFoundException
{
    final Class<?> result;
    try {
        result = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        return null;
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
    if (result == null) {
        throw new ClassNotFoundException(name);
    }
    return result;
}
项目:jdk8u-jdk    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:jdk8u-jdk    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
    throws ClassNotFoundException
{
    final Class<?> result;
    try {
        result = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        return null;
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
    if (result == null) {
        throw new ClassNotFoundException(name);
    }
    return result;
}
项目:Java8CN    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:Java8CN    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
    throws ClassNotFoundException
{
    final Class<?> result;
    try {
        result = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        return null;
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
    if (result == null) {
        throw new ClassNotFoundException(name);
    }
    return result;
}
项目:jdk8u_jdk    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:jdk8u_jdk    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
    throws ClassNotFoundException
{
    final Class<?> result;
    try {
        result = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        return null;
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
    if (result == null) {
        throw new ClassNotFoundException(name);
    }
    return result;
}
项目:lookaside_java-1.8.0-openjdk    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:lookaside_java-1.8.0-openjdk    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
    throws ClassNotFoundException
{
    final Class<?> result;
    try {
        result = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        return null;
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
    if (result == null) {
        throw new ClassNotFoundException(name);
    }
    return result;
}
项目:intellij-ce-playground    文件:aClassLoader.java   
/**
    * Find resources from the VM's built-in classloader.
    */
   private static Enumeration getBootstrapResources(String name)
throws IOException
   {
final Enumeration e = getBootstrapClassPath().getResources(name);
return new Enumeration () {
    public Object nextElement() {
    return ((Resource)e.nextElement()).getURL();
    }
    public boolean hasMoreElements() {
    return e.hasMoreElements();
    }
};
   }
项目:intellij-ce-playground    文件:InstrumentationClassFinder.java   
public Resource getResource(String s, boolean flag) {
  int i = 0;
  for (Loader loader; (loader = getLoader(i)) != null; i++) {
    Resource resource = loader.getResource(s, flag);
    if (resource != null) {
      return resource;
    }
  }

  return null;
}
项目:intellij-ce-playground    文件:InstrumentationClassFinder.java   
public Resource getResource(String name, boolean flag) {
  try {
    final ZipFile file = acquireZipFile();
    if (file != null) {
      final ZipEntry entry = file.getEntry(name);
      if (entry != null) {
        return new JarResource(entry, new URL(getBaseURL(), name));
      }
    }
  }
  catch (Exception e) {
    return null;
  }
  return null;
}
项目:jemstone    文件:HotSpotJvmAwareSaJdiClassLoader.java   
@Override
public Resource getResource(String name) {
    final String originalName = name;
    if (name.equals(SA_JDI_PROPERTIES_FILE_NAME)
            || name.startsWith(SA_JDI_PACKAGE_PREFIX)) {
        name = SA_JDI_JVM_PREFIX + "/" + name;
    }
    return new DelegatedResource(originalName, super.getResource(name));
}
项目:jemstone    文件:HotSpotJvmAwareSaJdiClassLoader.java   
@Override
public Resource getResource(String name, boolean check) {
    final String originalName = name;
    if (name.equals(SA_JDI_PROPERTIES_FILE_NAME)
            || name.startsWith(SA_JDI_PACKAGE_PREFIX)) {
        name = SA_JDI_JVM_PREFIX + "/" + name;
    }
    return new DelegatedResource(originalName, super.getResource(name, check));
}
项目:VarJ    文件:ClassLoader.java   
/**
    * Find resources from the VM's built-in classloader.
    */
   private static Enumeration getBootstrapResources(String name)
throws IOException
   {
final Enumeration e = getBootstrapClassPath().getResources(name);
return new Enumeration () {
    public Object nextElement() {
    return ((Resource)e.nextElement()).getURL();
    }
    public boolean hasMoreElements() {
    return e.hasMoreElements();
    }
};
   }
项目:jdk-1.7-annotated    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:infobip-open-jdk-8    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:infobip-open-jdk-8    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
    throws ClassNotFoundException
{
    final Class<?> result;
    try {
        result = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        return null;
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
    if (result == null) {
        throw new ClassNotFoundException(name);
    }
    return result;
}
项目:jdk8u-dev-jdk    文件:ClassLoader.java   
/**
 * Find resources from the VM's built-in classloader.
 */
private static Enumeration<URL> getBootstrapResources(String name)
    throws IOException
{
    final Enumeration<Resource> e =
        getBootstrapClassPath().getResources(name);
    return new Enumeration<URL> () {
        public URL nextElement() {
            return e.nextElement().getURL();
        }
        public boolean hasMoreElements() {
            return e.hasMoreElements();
        }
    };
}
项目:jdk8u-dev-jdk    文件:URLClassLoader.java   
/**
 * Finds and loads the class with the specified name from the URL search
 * path. Any URLs referring to JAR files are loaded and opened as needed
 * until the class is found.
 *
 * @param name the name of the class
 * @return the resulting class
 * @exception ClassNotFoundException if the class could not be found,
 *            or if the loader is closed.
 * @exception NullPointerException if {@code name} is {@code null}.
 */
protected Class<?> findClass(final String name)
    throws ClassNotFoundException
{
    final Class<?> result;
    try {
        result = AccessController.doPrivileged(
            new PrivilegedExceptionAction<Class<?>>() {
                public Class<?> run() throws ClassNotFoundException {
                    String path = name.replace('.', '/').concat(".class");
                    Resource res = ucp.getResource(path, false);
                    if (res != null) {
                        try {
                            return defineClass(name, res);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        return null;
                    }
                }
            }, acc);
    } catch (java.security.PrivilegedActionException pae) {
        throw (ClassNotFoundException) pae.getException();
    }
    if (result == null) {
        throw new ClassNotFoundException(name);
    }
    return result;
}