rt/emul/mini/src/main/java/java/lang/ClassLoader.java
changeset 1333 8cb6ebbd4823
parent 772 d382dacfd73f
child 1375 a6c71e376889
     1.1 --- a/rt/emul/mini/src/main/java/java/lang/ClassLoader.java	Tue Feb 26 16:54:16 2013 +0100
     1.2 +++ b/rt/emul/mini/src/main/java/java/lang/ClassLoader.java	Thu Oct 03 14:45:25 2013 +0200
     1.3 @@ -180,7 +180,7 @@
     1.4       * @since  1.2
     1.5       */
     1.6      protected ClassLoader(ClassLoader parent) {
     1.7 -        throw new SecurityException();
     1.8 +        this.parent = parent;
     1.9      }
    1.10  
    1.11      /**
    1.12 @@ -199,7 +199,7 @@
    1.13       *          of a new class loader.
    1.14       */
    1.15      protected ClassLoader() {
    1.16 -        throw new SecurityException();
    1.17 +        this.parent = null;
    1.18      }
    1.19  
    1.20      // -- Class --
    1.21 @@ -845,8 +845,27 @@
    1.22       * @revised  1.4
    1.23       */
    1.24      public static ClassLoader getSystemClassLoader() {
    1.25 -        throw new SecurityException();
    1.26 +        if (SYSTEM == null) {
    1.27 +            SYSTEM = new ClassLoader() {
    1.28 +                @Override
    1.29 +                protected Enumeration<URL> findResources(String name) throws IOException {
    1.30 +                    return getSystemResources(name);
    1.31 +                }
    1.32 +
    1.33 +                @Override
    1.34 +                protected URL findResource(String name) {
    1.35 +                    return getSystemResource(name);
    1.36 +                }
    1.37 +
    1.38 +                @Override
    1.39 +                protected Class<?> findClass(String name) throws ClassNotFoundException {
    1.40 +                    return Class.forName(name);
    1.41 +                }
    1.42 +            };
    1.43 +        }
    1.44 +        return SYSTEM;
    1.45      }
    1.46 +    private static ClassLoader SYSTEM;
    1.47  
    1.48      // Returns true if the specified class loader can be found in this class
    1.49      // loader's delegation chain.
    1.50 @@ -870,7 +889,7 @@
    1.51      }
    1.52  
    1.53      private static URL getBootstrapResource(String name) {
    1.54 -        throw new UnsupportedOperationException();
    1.55 +        return Object.class.getResource("/" + name);
    1.56      }
    1.57  
    1.58      private static Enumeration<URL> getBootstrapResources(String name) {
    1.59 @@ -910,7 +929,7 @@
    1.60          }
    1.61  
    1.62          public boolean hasMoreElements() {
    1.63 -            if (next == null) {
    1.64 +            if (next == null && index < arr.length) {
    1.65                  if (arr[index].hasMoreElements()) {
    1.66                      next = (URL) arr[index].nextElement();
    1.67                  } else {