diff -r c6f21b56a6cf -r f36b3c273de6 vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Sun Dec 09 16:43:36 2012 +0100 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Wed Dec 12 09:09:42 2012 +0100 @@ -20,6 +20,9 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; import javax.script.Invocable; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; @@ -269,7 +272,8 @@ ) throws Exception { Object ret = null; try { - ret = toRun.invokeFunction(clazz.getName().replace('.', '_'), true); + ret = toRun.invokeFunction("bck2brwsr"); + ret = toRun.invokeMethod(ret, "loadClass", clazz.getName()); ret = toRun.invokeMethod(ret, method, args); } catch (ScriptException ex) { fail("Execution failed in\n" + dumpJS(theCode), ex); @@ -295,7 +299,7 @@ if (sb == null) { sb = new StringBuilder(); } - GenJS.compile(sb, names); + Bck2Brwsr.generate(sb, new EmulationResources(), names); ScriptEngineManager sem = new ScriptEngineManager(); ScriptEngine js = sem.getEngineByExtension("js"); if (eng != null) { @@ -320,4 +324,21 @@ w.close(); return new StringBuilder(f.getPath()); } + private static class EmulationResources implements Bck2Brwsr.Resources { + @Override + public InputStream get(String name) throws IOException { + Enumeration en = StaticMethodTest.class.getClassLoader().getResources(name); + URL u = null; + while (en.hasMoreElements()) { + u = en.nextElement(); + } + if (u == null) { + throw new IOException("Can't find " + name); + } + if (u.toExternalForm().contains("rt.jar!")) { + throw new IOException("No emulation for " + u); + } + return u.openStream(); + } + } }