* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / tests / network / classloader.java
1 import java.security.AccessController;
2 import sun.security.action.*;
3 import java.io.File;
4
5 public class classloader {
6     private static String[] initializePath(String propname) {
7         String ldpath = System.getProperty(propname, "");
8         String ps = File.pathSeparator;
9         int ldlen = ldpath.length();
10         int i, j, n;
11         // Count the separators in the path
12         i = ldpath.indexOf(ps);
13         n = 0;
14         while (i >= 0) {
15             n++;
16             i = ldpath.indexOf(ps, i+1);
17         }
18
19         // allocate the array of paths - n :'s = n + 1 path elements
20         String[] paths = new String[n + 1];
21
22         // Fill the array with paths from the ldpath
23         n = i = 0;
24         j = ldpath.indexOf(ps);
25         while (j >= 0) {
26             if (j - i > 0) {
27                 paths[n++] = ldpath.substring(i, j);
28             } else if (j - i == 0) { 
29                 paths[n++] = ".";
30             }
31             i = j + 1;
32             j = ldpath.indexOf(ps, i);
33         }
34         paths[n] = ldpath.substring(i, ldlen);
35         return paths;
36     }
37
38     public static void main (String args[]) {
39         /*
40         String dirs[] = initializePath("sun.boot.library.path");
41
42         System.out.println("length: " + dirs.length);
43         for (int i = 0; i < dirs.length; ++i) {
44             System.out.println(dirs[i]);
45         }
46         */
47         AccessController.doPrivileged(new LoadLibraryAction("net"));
48     }
49 }