jdk/src/share/classes/java/net/URLClassLoader.java
changeset 10596 39b3a979e600
parent 9035 1255eb81cc2f
child 15682 793a36de151d
equal deleted inserted replaced
10595:c5be3e19fbab 10596:39b3a979e600
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package java.net;
    26 package java.net;
    27 
    27 
    28 import java.lang.reflect.Method;
       
    29 import java.lang.reflect.Modifier;
       
    30 import java.lang.ref.*;
       
    31 import java.io.*;
    28 import java.io.*;
    32 import java.net.URL;
       
    33 import java.net.URLConnection;
       
    34 import java.net.URLStreamHandlerFactory;
       
    35 import java.util.Enumeration;
       
    36 import java.util.*;
    29 import java.util.*;
    37 import java.util.jar.Manifest;
    30 import java.util.jar.Manifest;
    38 import java.util.jar.JarFile;
    31 import java.util.jar.JarFile;
    39 import java.util.jar.Attributes;
    32 import java.util.jar.Attributes;
    40 import java.util.jar.Attributes.Name;
    33 import java.util.jar.Attributes.Name;
   350     protected Class<?> findClass(final String name)
   343     protected Class<?> findClass(final String name)
   351          throws ClassNotFoundException
   344          throws ClassNotFoundException
   352     {
   345     {
   353         try {
   346         try {
   354             return AccessController.doPrivileged(
   347             return AccessController.doPrivileged(
   355                 new PrivilegedExceptionAction<Class>() {
   348                 new PrivilegedExceptionAction<Class<?>>() {
   356                     public Class run() throws ClassNotFoundException {
   349                     public Class<?> run() throws ClassNotFoundException {
   357                         String path = name.replace('.', '/').concat(".class");
   350                         String path = name.replace('.', '/').concat(".class");
   358                         Resource res = ucp.getResource(path, false);
   351                         Resource res = ucp.getResource(path, false);
   359                         if (res != null) {
   352                         if (res != null) {
   360                             try {
   353                             try {
   361                                 return defineClass(name, res);
   354                                 return defineClass(name, res);
   404     /*
   397     /*
   405      * Defines a Class using the class bytes obtained from the specified
   398      * Defines a Class using the class bytes obtained from the specified
   406      * Resource. The resulting Class must be resolved before it can be
   399      * Resource. The resulting Class must be resolved before it can be
   407      * used.
   400      * used.
   408      */
   401      */
   409     private Class defineClass(String name, Resource res) throws IOException {
   402     private Class<?> defineClass(String name, Resource res) throws IOException {
   410         long t0 = System.nanoTime();
   403         long t0 = System.nanoTime();
   411         int i = name.lastIndexOf('.');
   404         int i = name.lastIndexOf('.');
   412         URL url = res.getCodeSourceURL();
   405         URL url = res.getCodeSourceURL();
   413         if (i != -1) {
   406         if (i != -1) {
   414             String pkgname = name.substring(0, i);
   407             String pkgname = name.substring(0, i);
   772 
   765 
   773     FactoryURLClassLoader(URL[] urls, AccessControlContext acc) {
   766     FactoryURLClassLoader(URL[] urls, AccessControlContext acc) {
   774         super(urls, acc);
   767         super(urls, acc);
   775     }
   768     }
   776 
   769 
   777     public final Class loadClass(String name, boolean resolve)
   770     public final Class<?> loadClass(String name, boolean resolve)
   778         throws ClassNotFoundException
   771         throws ClassNotFoundException
   779     {
   772     {
   780         // First check if we have permission to access the package. This
   773         // First check if we have permission to access the package. This
   781         // should go away once we've added support for exported packages.
   774         // should go away once we've added support for exported packages.
   782         SecurityManager sm = System.getSecurityManager();
   775         SecurityManager sm = System.getSecurityManager();