Don't provide resources from rt.jar when generating bck2brwsr.js as the minimal library is not self contained anymore - but we still want as small bck2brwsr.js as possible
1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java Wed Oct 09 17:59:11 2013 +0200
1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java Wed Oct 09 22:02:34 2013 +0200
1.3 @@ -151,7 +151,7 @@
1.4 * @since 0.5
1.5 */
1.6 public Bck2Brwsr resources(final ClassLoader loader) {
1.7 - return resources(new LdrRsrcs(loader));
1.8 + return resources(new LdrRsrcs(loader, false));
1.9 }
1.10
1.11 /** Generates virtual machine based on previous configuration of the
1.12 @@ -161,7 +161,7 @@
1.13 * @since 0.5
1.14 */
1.15 public void generate(Appendable out) throws IOException {
1.16 - Resources r = res != null ? res : new LdrRsrcs(Bck2Brwsr.class.getClassLoader());
1.17 + Resources r = res != null ? res : new LdrRsrcs(Bck2Brwsr.class.getClassLoader(), false);
1.18 if (level != ObfuscationLevel.NONE) {
1.19 try {
1.20 ClosureWrapper.produceTo(out, level, r, classes);
2.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/LdrRsrcs.java Wed Oct 09 17:59:11 2013 +0200
2.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/LdrRsrcs.java Wed Oct 09 22:02:34 2013 +0200
2.3 @@ -28,9 +28,11 @@
2.4 */
2.5 final class LdrRsrcs implements Bck2Brwsr.Resources {
2.6 private final ClassLoader loader;
2.7 + private final boolean skipRtJar;
2.8
2.9 - LdrRsrcs(ClassLoader loader) {
2.10 + LdrRsrcs(ClassLoader loader, boolean skipRtJar) {
2.11 this.loader = loader;
2.12 + this.skipRtJar = skipRtJar;
2.13 }
2.14
2.15 @Override
2.16 @@ -43,6 +45,9 @@
2.17 if (u == null) {
2.18 throw new IOException("Can't find " + name);
2.19 }
2.20 + if (skipRtJar && u.toExternalForm().contains("rt.jar!")) {
2.21 + return null;
2.22 + }
2.23 return u.openStream();
2.24 }
2.25 }
3.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/Main.java Wed Oct 09 17:59:11 2013 +0200
3.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/Main.java Wed Oct 09 22:02:34 2013 +0200
3.3 @@ -93,7 +93,7 @@
3.4 Bck2Brwsr.newCompiler().
3.5 obfuscation(obfLevel).
3.6 addRootClasses(classes.toArray()).
3.7 - resources(Main.class.getClassLoader()).
3.8 + resources(new LdrRsrcs(Main.class.getClassLoader(), true)).
3.9 generate(w);
3.10 }
3.11 }