< prev index next >

test/java/lang/ClassLoader/deadlock/DelegatingLoader.java

Print this page




  58             System.exit(1);
  59         }
  60         System.out.println("Parallel ClassLoader registration: " +
  61                     supportParallel);
  62     }
  63 
  64     public DelegatingLoader(URL urls[]) {
  65         super(urls);
  66         System.out.println("DelegatingLoader using URL " + urls[0]);
  67     }
  68 
  69     public void setDelegate(String[] delClasses, DelegatingLoader delLoader) {
  70         this.delClasses = delClasses;
  71         this.delLoader = delLoader;
  72     }
  73 
  74     public Class loadClass(String className, boolean resolve)
  75             throws ClassNotFoundException {
  76         for (int i = 0; i < delClasses.length; i++) {
  77             if (delClasses[i].equals(className)) {
  78                 Starter.log("Delegating class loading for " + className);
  79                 try {
  80                     Thread.sleep(500);
  81                 } catch (InterruptedException ie) {
  82                     return null;
  83                 }
  84                 return delLoader.loadClass(className, resolve);
  85             }
  86         }
  87 
  88         Starter.log("Loading local class " + className);
  89 //        synchronized (getClassLoadingLock(className)) {
  90             return super.loadClass(className, resolve);
  91 //        }
  92     }
  93 }


  58             System.exit(1);
  59         }
  60         System.out.println("Parallel ClassLoader registration: " +
  61                     supportParallel);
  62     }
  63 
  64     public DelegatingLoader(URL urls[]) {
  65         super(urls);
  66         System.out.println("DelegatingLoader using URL " + urls[0]);
  67     }
  68 
  69     public void setDelegate(String[] delClasses, DelegatingLoader delLoader) {
  70         this.delClasses = delClasses;
  71         this.delLoader = delLoader;
  72     }
  73 
  74     public Class loadClass(String className, boolean resolve)
  75             throws ClassNotFoundException {
  76         for (int i = 0; i < delClasses.length; i++) {
  77             if (delClasses[i].equals(className)) {
  78                 DelegateTest.log("Delegating class loading for " + className);
  79                 try {
  80                     Thread.sleep(500);
  81                 } catch (InterruptedException ie) {
  82                     return null;
  83                 }
  84                 return delLoader.loadClass(className, resolve);
  85             }
  86         }
  87 
  88         DelegateTest.log("Loading local class " + className);
  89 //        synchronized (getClassLoadingLock(className)) {
  90             return super.loadClass(className, resolve);
  91 //        }
  92     }
  93 }
< prev index next >