aboutsummaryrefslogtreecommitdiff
path: root/nailgun_launcher/MultiClassLoader2.java
blob: fadd963c8ab9933988fd983eeb7c44a52602fdfb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package cbt;
import java.net.*;
import java.util.*;

public class MultiClassLoader2 extends ClassLoader{
  public ClassLoader[] parents;
  public ClassLoader[] parents(){
    return this.parents;
  }
  public MultiClassLoader2(ClassLoader... parents){
    super(null);
    this.parents = parents;
  }
  public Class findClass(String name) throws ClassNotFoundException{
    for(ClassLoader parent: parents){
      try{
        return parent.loadClass(name);
      } catch (ClassNotFoundException e) {
        if(e.getMessage() != name) throw e;
      }
    }
    // FIXME: have a logger in Java land
    // System.err.println("NOT FOUND: "+name);
    return null;
  }
  public String toString(){
    return super.toString() + "(" + Arrays.toString(parents) +")";
  }
}