1.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Tue Oct 16 12:42:00 2012 +0200
1.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Tue Oct 16 16:51:22 2012 +0200
1.3 @@ -55,6 +55,9 @@
1.4 compile(out, Arrays.asList(names));
1.5 }
1.6 static void compile(Appendable out, List<String> names) throws IOException {
1.7 + compile(GenJS.class.getClassLoader(), out, names);
1.8 + }
1.9 + static void compile(ClassLoader l, Appendable out, List<String> names) throws IOException {
1.10 for (String baseClass : names) {
1.11 Map<String,String> processed = new HashMap<String, String>();
1.12 LinkedList<String> toProcess = new LinkedList<String>();
1.13 @@ -92,7 +95,7 @@
1.14 processed.put(name, "");
1.15 continue;
1.16 }
1.17 - InputStream is = loadClass(name);
1.18 + InputStream is = loadClass(l, name);
1.19 if (is == null) {
1.20 throw new IOException("Can't find class " + name);
1.21 }
1.22 @@ -119,7 +122,10 @@
1.23 }
1.24 }
1.25 for (String resource : scripts) {
1.26 - InputStream emul = GenJS.class.getResourceAsStream(resource);
1.27 + while (resource.startsWith("/")) {
1.28 + resource = resource.substring(1);
1.29 + }
1.30 + InputStream emul = l.getResourceAsStream(resource);
1.31 if (emul == null) {
1.32 throw new IOException("Can't find " + resource);
1.33 }
1.34 @@ -183,12 +189,13 @@
1.35 }
1.36 }
1.37
1.38 - private static InputStream loadClass(String name) throws IOException {
1.39 - Enumeration<URL> en = ClassLoader.getSystemClassLoader().getResources(name + ".class");
1.40 + private static InputStream loadClass(ClassLoader l, String name) throws IOException {
1.41 + Enumeration<URL> en = l.getResources(name + ".class");
1.42 URL u = null;
1.43 while (en.hasMoreElements()) {
1.44 u = en.nextElement();
1.45 }
1.46 + System.err.println("loader: " + l + " url : " + u);
1.47 if (u == null) {
1.48 throw new IOException("Can't find " + name);
1.49 }