mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-20 01:09:28 +08:00
6aaeb97551
2000-08-26 Anthony Green <green@redhat.com> * Makefile.in: Rebuilt. * Makefile.am (java/lang/ClassLoader.h): Make _Jv_RunMain a friend. * prims.cc: Include ClassLoader.h. (_Jv_RunMain): When executing jar files, classpath must be the jar file only. Lose our reference to the system ClassLoader in order to get a new one with the correct classpath. * java/lang/natSystem.cc (init_properties): When executing a jar file, only use the jar file for java.class.path. * gnu/gcj/runtime/VMClassLoader.java: Use the canonical file name for bytecode archives. * gnu/gcj/runtime/FirstThread.java: Handle case where manifest exists, but not Main-Class. From-SVN: r35999
83 lines
2.1 KiB
Java
83 lines
2.1 KiB
Java
/* Copyright (C) 1999 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;
|
|
|
|
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(".jar") || e.endsWith (".zip"))
|
|
{
|
|
File archive = new File (e);
|
|
try {
|
|
p.addElement(new URL("jar", "", -1, "file://"
|
|
+ archive.getCanonicalPath ()
|
|
+ "!/"));
|
|
} catch (IOException ex) {
|
|
// empty
|
|
}
|
|
}
|
|
else if (e.endsWith ("/"))
|
|
p.addElement (new URL("file", "", -1, e));
|
|
else if (new File (e).isDirectory ())
|
|
p.addElement (new URL("file", "", -1, e + "/"));
|
|
else
|
|
/* Ignore path element. */;
|
|
}
|
|
catch (java.net.MalformedURLException x)
|
|
{
|
|
/* Ignore this path element */
|
|
}
|
|
}
|
|
|
|
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.
|
|
*/
|
|
protected final native Class findSystemClass(String name)
|
|
throws java.lang.ClassNotFoundException, java.lang.LinkageError;
|
|
|
|
// Return the sole VMClassLoader.
|
|
private static synchronized VMClassLoader getVMClassLoader ()
|
|
{
|
|
if (redirect == null)
|
|
redirect = new VMClassLoader ();
|
|
return redirect;
|
|
}
|
|
|
|
// The only VMClassLoader that can exist.
|
|
private static VMClassLoader redirect;
|
|
}
|