OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [java/] [net/] [loader/] [Load_gcjlib.java] - Blame information for rev 756

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
/* Copyright (C) 2007  Free Software Foundation
2
 
3
   This file is part of libgcj.
4
 
5
This software is copyrighted work licensed under the terms of the
6
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7
details.  */
8
 
9
package gnu.java.net.loader;
10
 
11
import gnu.gcj.runtime.SharedLibHelper;
12
import java.io.InputStream;
13
import java.io.IOException;
14
import java.net.URL;
15
import java.net.URLClassLoader;
16
import java.net.URLConnection;
17
import java.net.URLStreamHandlerFactory;
18
 
19
/**
20
 * A <code>Load_gcjlib</code> is a type of <code>URLLoader</code>
21
 * that loads classes and resources from a shared library.
22
 */
23
public final class Load_gcjlib extends URLLoader
24
{
25
  private SharedLibHelper helper;
26
 
27
  public Load_gcjlib(URLClassLoader classloader,
28
                     URLStreamHandlerCache cache,
29
                     URLStreamHandlerFactory factory,
30
                     URL url, URL absoluteUrl)
31
  {
32
    super(classloader, cache, factory, url, absoluteUrl);
33
    helper = SharedLibHelper.findHelper(classloader, url.getFile(),
34
                                        noCertCodeSource, true);
35
  }
36
 
37
  public Class getClass(String className)
38
  {
39
    return helper.findClass(className);
40
  }
41
 
42
  public Resource getResource(String name)
43
  {
44
    URL url = helper.findResource(name);
45
    if (url == null)
46
      return null;
47
    return new SoResource(this, url);
48
  }
49
 
50
  final static class SoResource extends Resource
51
  {
52
    private final URL url;
53
 
54
    SoResource(Load_gcjlib loader, URL url)
55
    {
56
      super(loader);
57
      this.url = url;
58
    }
59
 
60
    public InputStream getInputStream() throws IOException
61
    {
62
      URLConnection conn = url.openConnection();
63
      return conn.getInputStream();
64
    }
65
 
66
    public int getLength()
67
    {
68
      // FIXME we could find this by asking the core object.
69
      return -1;
70
    }
71
 
72
    public URL getURL ()
73
    {
74
      return url;
75
    }
76
  }
77
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.