source: trunk/gcc/libjava/gnu/gcj/runtime/SharedLibLoader.java

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1/* Copyright (C) 2001, 2003 Free Software Foundation
2
3 This file is part of libgcj.
4
5This software is copyrighted work licensed under the terms of the
6Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7details. */
8
9package gnu.gcj.runtime;
10import java.util.Hashtable;
11
12/**
13 * A ClassLoader backed by a gcj-compiled shared library.
14 * @author Per Bothner <per@bothner.com>, Brainfood Inc.
15 */
16
17public class SharedLibLoader extends ClassLoader
18{
19 public native void finalize ();
20
21 /** Called during dlopen's processing of the init section. */
22 void registerClass(String name, Class cls)
23 {
24 classMap.put(name, cls);
25 }
26
27 /** Load a shared library, and associate a ClassLoader with it.
28 * @param libname named of shared library (passed to dlopen)
29 * @param parent the parent ClassLoader
30 * @param flags passed to dlopen
31 */
32 public SharedLibLoader(String libname, ClassLoader parent, int flags)
33 {
34 super(parent);
35 init(libname, flags);
36 }
37
38
39 /** Load a shared library, and asociate a ClassLoader with it.
40 * @param libname named of shared library (passed to dlopen)
41 */
42 public SharedLibLoader(String libname)
43 {
44 super(getSystemClassLoader());
45 init(libname, 0);
46 }
47
48 void init(String libname, int flags)
49 {
50 init(libname.getBytes(), flags);
51 }
52
53 native void init(byte[] libname, int flags);
54
55 public Class loadClass(String name)
56 throws ClassNotFoundException
57 {
58 return super.loadClass(name);
59 }
60
61 public Class findClass(String name)
62 throws ClassNotFoundException
63 {
64 Object cls = classMap.get(name);
65 if (cls == null)
66 throw new ClassNotFoundException(name);
67 return (Class) cls;
68 }
69
70 /** The handle returned by dlopen. */
71 gnu.gcj.RawData handler;
72
73 /** Map classnames to Classes. */
74 Hashtable classMap = new Hashtable(20);
75}
Note: See TracBrowser for help on using the repository browser.