1.1 --- a/src/test/java/org/apidesign/java4browser/StaticMethodTest.java Thu Sep 20 14:20:01 2012 +0200
1.2 +++ b/src/test/java/org/apidesign/java4browser/StaticMethodTest.java Thu Sep 20 14:35:21 2012 +0200
1.3 @@ -20,7 +20,9 @@
1.4 import java.io.IOException;
1.5 import java.io.InputStream;
1.6 import java.util.Arrays;
1.7 +import java.util.HashSet;
1.8 import java.util.Iterator;
1.9 +import java.util.LinkedList;
1.10 import java.util.Set;
1.11 import java.util.TreeSet;
1.12 import javax.script.Invocable;
1.13 @@ -156,13 +158,25 @@
1.14 }
1.15
1.16 static Invocable compileClass(StringBuilder sb, String... names) throws ScriptException, IOException {
1.17 - for (String name : names) {
1.18 + if (sb == null) {
1.19 + sb = new StringBuilder();
1.20 + }
1.21 + Set<String> processed = new HashSet<String>();
1.22 +
1.23 + LinkedList<String> toProcess = new LinkedList<String>(Arrays.asList(names));
1.24 + for (;;) {
1.25 + toProcess.removeAll(processed);
1.26 + if (toProcess.isEmpty()) {
1.27 + break;
1.28 + }
1.29 + String name = toProcess.getFirst();
1.30 + processed.add(name);
1.31 + if (name.startsWith("java/") && !name.equals("java/lang/Object")) {
1.32 + continue;
1.33 + }
1.34 InputStream is = StaticMethodTest.class.getClassLoader().getResourceAsStream(name + ".class");
1.35 assertNotNull(is, "Class file found");
1.36 - if (sb == null) {
1.37 - sb = new StringBuilder();
1.38 - }
1.39 - ByteCodeToJavaScript.compile(is, sb, null);
1.40 + ByteCodeToJavaScript.compile(is, sb, toProcess);
1.41 }
1.42 ScriptEngineManager sem = new ScriptEngineManager();
1.43 ScriptEngine js = sem.getEngineByExtension("js");