1 /* Copyright (C) 2005 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 package gnu
.gcj
.runtime
;
12 import java
.io
.FilenameFilter
;
13 import java
.io
.IOException
;
15 import java
.net
.URLClassLoader
;
16 import java
.util
.StringTokenizer
;
19 * This is a URLClassLoader that has an extra helper method for
20 * handling things like java.ext.dirs.
22 class HelperClassLoader
extends URLClassLoader
29 HelperClassLoader(ClassLoader parent
)
31 super(new URL
[0], parent
);
35 * This is a helper method that adds all the jar and zip files from
36 * a given list of paths to this class loader. The paths are taken
37 * from a system property whose name is provided as an argument.
39 final void addDirectoriesFromProperty(String propName
)
42 = new StringTokenizer (System
.getProperty (propName
, ""),
46 while (st
.hasMoreElements ())
48 String dirname
= st
.nextToken ();
49 File dir
= new File (dirname
);
52 if (! dirname
.endsWith (File
.separator
))
53 dirname
= dirname
+ File
.separator
;
54 String files
[] = dir
.list (new FilenameFilter ()
56 public boolean accept (File dir
, String name
)
58 return name
.endsWith (".jar") || name
.endsWith (".zip");
61 for (int i
= files
.length
- 1; i
>= 0; i
--)
62 addURL(new URL("file", "", -1, dirname
+ files
[i
]));
66 catch (java
.net
.MalformedURLException x
)
68 // This should never happen.
69 throw new RuntimeException(x
);