diff -r 3b960d9631b2 -r fd3a354d6e8f rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Sun Nov 09 06:54:07 2014 +0100 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Sun Nov 09 10:36:08 2014 +0100 @@ -235,11 +235,7 @@ while (resource.startsWith("/")) { resource = resource.substring(1); } - InputStream emul = resources.get(resource); - if (emul == null) { - throw new IOException("Can't find " + resource); - } - readResource(emul, this); + requireResourceImpl(resource); asBinary.remove(resource); } scripts = new StringArray(); @@ -260,6 +256,14 @@ } } + final void requireResourceImpl(String resource) throws IOException { + InputStream emul = resources.get(resource); + if (emul == null) { + throw new IOException("Can't find " + resource); + } + readResource(emul, this); + } + private static void readResource(InputStream emul, Appendable out) throws IOException { try { int state = 0; @@ -703,6 +707,11 @@ out.append("\n return vm.").append(cls).append("(instance);"); out.append("\n}"); } + + @Override + protected void requireResource(String resourcePath) throws IOException { + requireResourceImpl(resourcePath); + } } private static final class Extension extends VM { @@ -795,5 +804,10 @@ out.append(cls).append(" = f;})(instance);"); out.append("\n}"); } + + @Override + protected void requireResource(String resourcePath) throws IOException { + requireResourceImpl(resourcePath); + } } }