mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-19 16:40:04 +08:00
e825ca7ff5
* gnu/gcj/protocol/jar/Connection.java (getJarFile): download and cache remote jar files. * gnu/gcj/runtime/VMClassLoader.java: Don't construct jar URL, only add File.separator to URL when it is a directory. * java/lang/ClassLoader.java: Add Classpath javadoc. (parent): final. (getParent): Add (disabled) security check. (findLibrary): New default method. * java/net/JarURLConnection.java (getManifest): Implement. (getInputStream): Only create InputStream when entry exists. (getHeaders): Only use jarFileURLConnection or JarEntry to set length when they exist. * java/net/URLClassLoader.java: New/Rewritten version from Classpath. From-SVN: r59949
73 lines
1.9 KiB
Java
73 lines
1.9 KiB
Java
/* Copyright (C) 1999, 2001, 2002 Free Software Foundation
|
|
|
|
This file is part of libgcj.
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
details. */
|
|
|
|
/* Author: Kresten Krab Thorup <krab@gnu.org> */
|
|
|
|
package gnu.gcj.runtime;
|
|
|
|
import java.io.*;
|
|
import java.util.StringTokenizer;
|
|
import java.net.URL;
|
|
|
|
public final class VMClassLoader extends java.net.URLClassLoader
|
|
{
|
|
private VMClassLoader ()
|
|
{
|
|
super (init());
|
|
}
|
|
|
|
private static URL[] init()
|
|
{
|
|
StringTokenizer st
|
|
= new StringTokenizer (System.getProperty ("java.class.path", "."),
|
|
System.getProperty ("path.separator", ":"));
|
|
|
|
java.util.Vector p = new java.util.Vector();
|
|
while (st.hasMoreElements ())
|
|
{
|
|
String e = st.nextToken ();
|
|
try
|
|
{
|
|
if (!e.endsWith (File.separator) && new File (e).isDirectory ())
|
|
p.addElement (new URL("file", "", -1, e + File.separator));
|
|
else
|
|
p.addElement (new URL("file", "", -1, e));
|
|
}
|
|
catch (java.net.MalformedURLException x)
|
|
{
|
|
/* Ignore this path element */
|
|
}
|
|
}
|
|
// Add core:/ to the end of the java.class.path so any resources
|
|
// compiled into this executable may be found.
|
|
try
|
|
{
|
|
p.addElement (new URL("core", "", -1, "/"));
|
|
}
|
|
catch (java.net.MalformedURLException x)
|
|
{
|
|
// This should never happen.
|
|
}
|
|
|
|
URL[] urls = new URL[p.size()];
|
|
p.copyInto (urls);
|
|
return urls;
|
|
}
|
|
|
|
/** This is overridden to search the internal hash table, which
|
|
* will only search existing linked-in classes. This will make
|
|
* the default implementation of loadClass (in ClassLoader) work right.
|
|
* The implementation of this method is in java/lang/natClassLoader.cc.
|
|
*/
|
|
protected native Class findClass(String name)
|
|
throws java.lang.ClassNotFoundException;
|
|
|
|
// The only VMClassLoader that can exist.
|
|
public static VMClassLoader instance = new VMClassLoader ();
|
|
}
|