1.1 --- a/rt/emul/mini/src/main/java/java/lang/ClassLoader.java Thu Oct 03 14:45:25 2013 +0200
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/ClassLoader.java Sun Oct 20 20:36:03 2013 +0200
1.3 @@ -24,6 +24,7 @@
1.4 */
1.5 package java.lang;
1.6
1.7 +import java.io.ByteArrayInputStream;
1.8 import java.io.InputStream;
1.9 import java.io.IOException;
1.10 import java.net.URL;
1.11 @@ -892,9 +893,45 @@
1.12 return Object.class.getResource("/" + name);
1.13 }
1.14
1.15 + @JavaScriptBody(args = { "name", "skip" }, body
1.16 + = "return (vm.loadBytes) ? vm.loadBytes(name, skip) : null;"
1.17 + )
1.18 + static native byte[] getResourceAsStream0(String name, int skip);
1.19 +
1.20 private static Enumeration<URL> getBootstrapResources(String name) {
1.21 - URL u = Object.class.getResource("/" + name);
1.22 - return new OneOrZeroEnum(u);
1.23 + return new ResEnum(name);
1.24 + }
1.25 +
1.26 + private static class ResEnum implements Enumeration<URL> {
1.27 + private final String name;
1.28 + private URL next;
1.29 + private int skip;
1.30 +
1.31 + public ResEnum(String name) {
1.32 + this.name = name;
1.33 + }
1.34 +
1.35 +
1.36 + public boolean hasMoreElements() {
1.37 + if (next == null && skip >= 0) {
1.38 + byte[] arr = getResourceAsStream0(name, skip++);
1.39 + if (arr != null) {
1.40 + next = Class.newResourceURL(name, new ByteArrayInputStream(arr));
1.41 + } else {
1.42 + skip = -1;
1.43 + }
1.44 + }
1.45 + return next != null;
1.46 + }
1.47 +
1.48 + public URL nextElement() {
1.49 + URL r = next;
1.50 + if (r == null) {
1.51 + throw new NoSuchElementException();
1.52 + }
1.53 + next = null;
1.54 + return r;
1.55 + }
1.56 }
1.57
1.58 private static class OneOrZeroEnum implements Enumeration<URL> {