1 /* Copyright (C) 2001, 2003 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
;
10 import java
.io
.IOException
;
11 import java
.net
.MalformedURLException
;
13 import java
.security
.CodeSource
;
14 import java
.util
.Enumeration
;
15 import java
.util
.Vector
;
18 * A ClassLoader backed by a gcj-compiled shared library.
19 * @author Per Bothner <per@bothner.com>, Brainfood Inc.
22 public class SharedLibLoader
extends ClassLoader
24 /** Load a shared library, and associate a ClassLoader with it.
25 * @param libname named of shared library (passed to dlopen)
26 * @param parent the parent ClassLoader
27 * @parem flags passed to dlopen
29 public SharedLibLoader(String libname
, ClassLoader parent
, int flags
)
35 url
= new URL("file", "", libname
);
37 catch (MalformedURLException _
)
41 helper
= SharedLibHelper
.findHelper(this, libname
,
42 new CodeSource(url
, null), true);
45 /** Load a shared library, and asociate a ClassLoader with it.
46 * @param libname named of shared library (passed to dlopen)
48 public SharedLibLoader(String libname
)
50 this(libname
, getSystemClassLoader(), 0);
53 public Class
findClass(String name
)
54 throws ClassNotFoundException
56 Class cls
= helper
.findClass(name
);
58 throw new ClassNotFoundException(name
);
62 public URL
findResource (String name
)
64 return helper
.findResource(name
);
67 public Enumeration
findResources (String name
) throws IOException
69 URL url
= findResource(name
);
72 Vector v
= new Vector(1);
77 /** The helper that does the work for us. */
78 SharedLibHelper helper
;