natClassLoader.cc (_Jv_PrepareCompiledClass): Renamed from _Jv_InternClassStrings.
* java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Renamed from _Jv_InternClassStrings. * prims.cc (_Jv_RunMain): New function. (JvRunMain): Remove gij-support. * gij.cc (main): Use _Jv_RunMain. * java/util/zip/ZipFile.java: Call readDirectory in constructor. * interpret.cc (PUSHA, PUSHI, PUSHF, PUSHL, PUSHD): Don't store argument in temp variable. (continue1): For all op_x2y insns, use temp variable for intermediate value. Also remove some comments. * java/lang/natClass.cc (newInstance): Call _Jv_InitClass. (forName): Don't call _Jv_InitClass. * java/lang/Class.java (getResource,getResourceAsStream): Implement. * java/util/zip/ZipEntry.java (ZipEntry(ZipEntry)): New construcor. * java/util/jar/JarInputStream.java: New file. * java/util/jar/JarEntry.java: New file. * java/util/jar/JarFile.java: New file. * java/net/URLClassLoader.java: New file. * java/net/JarURLConnection.java: New file. * gnu/gcj/protocol/jar/Handler.java: New file. * gnu/gcj/protocol/jar/Connection.java: New file. * java/security/SecureClassLoader.java: New file. * java/lang/ClassLoader.java (parent): New variable. (ClassLoader (ClassLoader)): new constructor. (findClass): New method. (loadClass): Add default 1.2 implementation. (getSystemResourceAsBytes, getResourceAsBytes): Removed. (readfully): Removed. * gnu/gcj/runtime/VMClassLoader.java: Moved from java/lang. (findSystemClass): New method. (VMClassLoader): Constructor rewritten. (init): New method. All other methods removed. * java/lang/natClassLoader.cc: Change use of java::lang::VMClassLoader to gnu::gcj::runtime::VMClassLoader. (_Jv_InternClassStrings): Use _Jv_ResolvePoolEntry. Also handle class entries. (VMClassLoader::findSystemClass): renamed from findBootClass. * Makefile.am: Add new files. (FirstThread.h, ThreadGroup.h): Add _Jv_Main friend. * Makefile.in: Rebuilt. From-SVN: r28748
This commit is contained in:
parent
312f625598
commit
eb4534a636
26 changed files with 2195 additions and 517 deletions
|
@ -1,3 +1,67 @@
|
|||
1999-08-18 Kresten Krab Thorup <krab@gnu.org>
|
||||
|
||||
* java/lang/natClassLoader.cc (_Jv_PrepareCompiledClass): Renamed
|
||||
from _Jv_InternClassStrings.
|
||||
|
||||
* prims.cc (_Jv_RunMain): New function.
|
||||
(JvRunMain): Remove gij-support.
|
||||
|
||||
* gij.cc (main): Use _Jv_RunMain.
|
||||
|
||||
* java/util/zip/ZipFile.java: Call readDirectory in constructor.
|
||||
|
||||
* interpret.cc (PUSHA, PUSHI, PUSHF, PUSHL, PUSHD): Don't store
|
||||
argument in temp variable.
|
||||
(continue1): For all op_x2y insns, use temp variable for
|
||||
intermediate value. Also remove some comments.
|
||||
|
||||
* java/lang/natClass.cc (newInstance): Call _Jv_InitClass.
|
||||
(forName): Don't call _Jv_InitClass.
|
||||
|
||||
* java/lang/Class.java (getResource,getResourceAsStream): Implement.
|
||||
|
||||
* java/util/zip/ZipEntry.java (ZipEntry(ZipEntry)): New construcor.
|
||||
|
||||
* java/util/jar/JarInputStream.java: New file.
|
||||
|
||||
* java/util/jar/JarEntry.java: New file.
|
||||
|
||||
* java/util/jar/JarFile.java: New file.
|
||||
|
||||
* java/net/URLClassLoader.java: New file.
|
||||
|
||||
* java/net/JarURLConnection.java: New file.
|
||||
|
||||
* gnu/gcj/protocol/jar/Handler.java: New file.
|
||||
|
||||
* gnu/gcj/protocol/jar/Connection.java: New file.
|
||||
|
||||
* java/security/SecureClassLoader.java: New file.
|
||||
|
||||
* java/lang/ClassLoader.java (parent): New variable.
|
||||
(ClassLoader (ClassLoader)): new constructor.
|
||||
(findClass): New method.
|
||||
(loadClass): Add default 1.2 implementation.
|
||||
(getSystemResourceAsBytes, getResourceAsBytes): Removed.
|
||||
(readfully): Removed.
|
||||
|
||||
* gnu/gcj/runtime/VMClassLoader.java: Moved from java/lang.
|
||||
(findSystemClass): New method.
|
||||
(VMClassLoader): Constructor rewritten.
|
||||
(init): New method.
|
||||
All other methods removed.
|
||||
|
||||
* java/lang/natClassLoader.cc: Change use of java::lang::VMClassLoader
|
||||
to gnu::gcj::runtime::VMClassLoader.
|
||||
(_Jv_InternClassStrings): Use _Jv_ResolvePoolEntry. Also handle
|
||||
class entries.
|
||||
(VMClassLoader::findSystemClass): renamed from findBootClass.
|
||||
|
||||
* Makefile.am: Add new files.
|
||||
(FirstThread.h, ThreadGroup.h): Add _Jv_Main friend.
|
||||
|
||||
* Makefile.in: Rebuilt.
|
||||
|
||||
1999-08-17 Tom Tromey <tromey@cygnus.com>
|
||||
|
||||
* java/lang/natThread.cc (sleep): Turn 0 millis and 0 nanos into 1
|
||||
|
|
|
@ -201,16 +201,18 @@ nat_headers = $(ordinary_java_source_files:.java=.h) \
|
|||
$(nat_headers): libgcj.zip
|
||||
|
||||
## Our internal main program needs to be able to create a FirstThread.
|
||||
FTFRIEND = void JvRunMain (jclass klass, int argc, const char **argv)
|
||||
java/lang/FirstThread.h: java/lang/FirstThread.class libgcj.zip
|
||||
$(GCJH) -classpath $(top_builddir) -friend '$(FTFRIEND);' \
|
||||
$(GCJH) -classpath $(top_builddir) \
|
||||
-friend 'void JvRunMain (jclass, int, const char **);' \
|
||||
-friend 'void _Jv_RunMain (const char*, int, const char **);' \
|
||||
$(basename $<)
|
||||
|
||||
## ThreadGroup has a special constructor that is used when creating
|
||||
## the first ThreadGroup. We need to expose this to the main program.
|
||||
TGFRIEND = void JvRunMain (jclass klass, int argc, const char **argv)
|
||||
java/lang/ThreadGroup.h: java/lang/ThreadGroup.class libgcj.zip
|
||||
$(GCJH) -classpath $(top_builddir) -friend '$(TGFRIEND);' \
|
||||
$(GCJH) -classpath $(top_builddir) \
|
||||
-friend 'void JvRunMain (jclass, int, const char **);' \
|
||||
-friend 'void _Jv_RunMain (const char*, int, const char **);' \
|
||||
$(basename $<)
|
||||
|
||||
java/lang/String.h: java/lang/String.class libgcj.zip
|
||||
|
@ -236,7 +238,7 @@ java/lang/reflect/Method.h: java/lang/reflect/Method.class libgcj.zip
|
|||
-friend 'java::lang::Class;' \
|
||||
$(basename $<)
|
||||
|
||||
java/lang/VMClassLoader.h: java/lang/VMClassLoader.class libgcj.zip
|
||||
gnu/gcj/runtime/VMClassLoader.h: gnu/gcj/runtime/VMClassLoader.class libgcj.zip
|
||||
$(GCJH) -classpath $(top_builddir) \
|
||||
-friend 'java::lang::ClassLoader;' \
|
||||
$(basename $<)
|
||||
|
@ -481,6 +483,7 @@ built_java_source_files = java/lang/ConcreteProcess.java
|
|||
## header, please list it in special_java_source_files.
|
||||
ordinary_java_source_files = $(convert_source_files) \
|
||||
gnu/gcj/runtime/MethodInvocation.java \
|
||||
gnu/gcj/runtime/VMClassLoader.java \
|
||||
gnu/gcj/util/path/SearchPath.java \
|
||||
gnu/gcj/util/path/PathEntry.java \
|
||||
gnu/gcj/util/path/DirectoryPathEntry.java \
|
||||
|
@ -498,6 +501,8 @@ gnu/gcj/protocol/file/Connection.java \
|
|||
gnu/gcj/protocol/file/Handler.java \
|
||||
gnu/gcj/protocol/http/Connection.java \
|
||||
gnu/gcj/protocol/http/Handler.java \
|
||||
gnu/gcj/protocol/jar/Handler.java \
|
||||
gnu/gcj/protocol/jar/Connection.java \
|
||||
gnu/gcj/RawData.java \
|
||||
gnu/gcj/util/EnumerationChain.java \
|
||||
java/io/BufferedInputStream.java \
|
||||
|
@ -565,7 +570,6 @@ java/lang/ClassCastException.java \
|
|||
java/lang/ClassCircularityError.java \
|
||||
java/lang/ClassFormatError.java \
|
||||
java/lang/ClassLoader.java \
|
||||
java/lang/VMClassLoader.java \
|
||||
java/lang/ClassNotFoundException.java \
|
||||
java/lang/CloneNotSupportedException.java \
|
||||
java/lang/Cloneable.java \
|
||||
|
@ -643,6 +647,7 @@ java/net/DatagramSocketImpl.java \
|
|||
java/net/FileNameMap.java \
|
||||
java/net/HttpURLConnection.java \
|
||||
java/net/InetAddress.java \
|
||||
java/net/JarURLConnection.java \
|
||||
java/net/MalformedURLException.java \
|
||||
java/net/MulticastSocket.java \
|
||||
java/net/NoRouteToHostException.java \
|
||||
|
@ -656,6 +661,7 @@ java/net/SocketImpl.java \
|
|||
java/net/SocketImplFactory.java \
|
||||
java/net/SocketOptions.java \
|
||||
java/net/URL.java \
|
||||
java/net/URLClassLoader.java \
|
||||
java/net/URLConnection.java \
|
||||
java/net/URLDecoder.java \
|
||||
java/net/URLEncoder.java \
|
||||
|
@ -665,6 +671,7 @@ java/net/UnknownHostException.java \
|
|||
java/net/UnknownServiceException.java \
|
||||
java/security/MessageDigest.java \
|
||||
java/security/NoSuchAlgorithmException.java \
|
||||
java/security/SecureClassLoader.java \
|
||||
java/text/BreakIterator.java \
|
||||
java/text/CharacterIterator.java \
|
||||
java/text/ChoiceFormat.java \
|
||||
|
@ -711,6 +718,9 @@ java/util/StringTokenizer.java \
|
|||
java/util/TimeZone.java \
|
||||
java/util/TooManyListenersException.java \
|
||||
java/util/Vector.java \
|
||||
java/util/jar/JarFile.java \
|
||||
java/util/jar/JarInputStream.java \
|
||||
java/util/jar/JarEntry.java \
|
||||
java/util/zip/Adler32.java \
|
||||
java/util/zip/CRC32.java \
|
||||
java/util/zip/CheckedInputStream.java \
|
||||
|
|
1195
libjava/Makefile.in
1195
libjava/Makefile.in
File diff suppressed because it is too large
Load diff
|
@ -23,5 +23,5 @@ int main (int argc, const char **argv)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
JvRunMain (0, argc, argv);
|
||||
_Jv_RunMain (argv[1], argc-1, argv+1);
|
||||
}
|
||||
|
|
86
libjava/gnu/gcj/protocol/jar/Connection.java
Normal file
86
libjava/gnu/gcj/protocol/jar/Connection.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package gnu.gcj.protocol.jar;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.io.IOException;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* Written using on-line Java Platform 1.2 API Specification.
|
||||
* Status: Needs a way to download jar files and store them in the local file
|
||||
* system. I don't know how to do that in a portable way. For now, it can only handle
|
||||
* connections to a jar:file: url's.
|
||||
*
|
||||
* @author Kresten Krab Thorup <krab@gnu.org>
|
||||
* @date Aug 10, 1999.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public class Connection extends JarURLConnection
|
||||
{
|
||||
static Hashtable file_cache = new Hashtable();
|
||||
private JarFile jarfile;
|
||||
|
||||
public Connection(URL url)
|
||||
throws MalformedURLException
|
||||
{
|
||||
super(url);
|
||||
}
|
||||
|
||||
public synchronized JarFile getJarFile() throws java.io.IOException
|
||||
{
|
||||
if (!connected)
|
||||
connect();
|
||||
|
||||
if (! doInput)
|
||||
throw new ProtocolException("Can't open JarFile if doInput is false");
|
||||
|
||||
if (jarfile != null)
|
||||
return jarfile;
|
||||
|
||||
URL jarFileURL = getJarFileURL ();
|
||||
|
||||
if (jarFileURL.getProtocol ().equals ("file")
|
||||
&& jarFileURL.getHost ().equals (""))
|
||||
{
|
||||
if (getUseCaches())
|
||||
{
|
||||
jarfile = (JarFile) file_cache.get(jarFileURL);
|
||||
if (jarFileURL == null)
|
||||
{
|
||||
jarfile = new JarFile (jarFileURL.getFile ());
|
||||
file_cache.put (jarFileURL, jarfile);
|
||||
}
|
||||
}
|
||||
else
|
||||
jarfile = new JarFile (jarFileURL.getFile ());
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
FIXME: Here we need to download and cache the jar
|
||||
file in the local file system! Stupid design. Why
|
||||
can't we just create a JarFile from a bag of bytes?
|
||||
*/
|
||||
|
||||
throw new java.io.IOException("cannot create jar file from " +
|
||||
jarFileURL);
|
||||
}
|
||||
|
||||
return jarfile;
|
||||
}
|
||||
|
||||
}
|
29
libjava/gnu/gcj/protocol/jar/Handler.java
Normal file
29
libjava/gnu/gcj/protocol/jar/Handler.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Handler.java - URLStreamHandler for file protocol.
|
||||
|
||||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package gnu.gcj.protocol.jar;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Kresten Krab Thorup <krab@gnu.org>
|
||||
* @date August 13, 1999.
|
||||
*/
|
||||
|
||||
public class Handler extends URLStreamHandler
|
||||
{
|
||||
protected URLConnection openConnection(URL url) throws IOException
|
||||
{
|
||||
return new Connection(url);
|
||||
}
|
||||
}
|
62
libjava/gnu/gcj/runtime/VMClassLoader.java
Normal file
62
libjava/gnu/gcj/runtime/VMClassLoader.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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"))
|
||||
p.addElement(new URL("jar", "", -1, "file:///"+e+"!/"));
|
||||
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;
|
||||
}
|
|
@ -72,6 +72,7 @@ inline jobjectArray JvNewObjectArray (jsize length, jclass cls, jobject init)
|
|||
|
||||
extern "C" jstringArray JvConvertArgv(int argc, const char **argv);
|
||||
extern "C" void JvRunMain (jclass klass, int argc, const char **argv);
|
||||
void _Jv_RunMain (const char* name, int argc, const char **argv);
|
||||
|
||||
inline jsize JvGetArrayLength (jarray array) { return array->length; }
|
||||
|
||||
|
|
|
@ -109,22 +109,25 @@ static inline void dupx (_Jv_word *&sp, int n, int x)
|
|||
};
|
||||
|
||||
|
||||
#define PUSHA(V) \
|
||||
({ jobject __v=(V); (sp++)->o = __v; })
|
||||
#define PUSHI(V) \
|
||||
({ jint __v=(V); (sp++)->i = __v; })
|
||||
#define PUSHF(V) \
|
||||
({ jfloat __v=(V); (sp++)->f = __v; })
|
||||
#define PUSHL(V) \
|
||||
({ jlong __v=(V); _Jv_storeLong(sp,__v); sp+=2; })
|
||||
#define PUSHD(V) \
|
||||
({ jdouble __v=(V); _Jv_storeDouble(sp,__v); sp+=2; })
|
||||
#define PUSHA(V) (sp++)->o = (V)
|
||||
#define PUSHI(V) (sp++)->i = (V)
|
||||
#define PUSHF(V) (sp++)->f = (V)
|
||||
#define PUSHL(V) ({ _Jv_word2 w2; w2.l=(V); \
|
||||
(sp++)->ia[0] = w2.ia[0]; \
|
||||
(sp++)->ia[0] = w2.ia[1]; })
|
||||
#define PUSHD(V) ({ _Jv_word2 w2; w2.d=(V); \
|
||||
(sp++)->ia[0] = w2.ia[0]; \
|
||||
(sp++)->ia[0] = w2.ia[1]; })
|
||||
|
||||
#define POPA() ((--sp)->o)
|
||||
#define POPI() ((jint) (--sp)->i) // cast since it may be promoted
|
||||
#define POPF() ((jfloat) (--sp)->f)
|
||||
#define POPL() ({ sp-=2; _Jv_loadLong (sp); })
|
||||
#define POPD() ({ sp-=2; _Jv_loadDouble (sp); })
|
||||
#define POPL() ({ _Jv_word2 w2; \
|
||||
w2.ia[1] = (--sp)->ia[0]; \
|
||||
w2.ia[0] = (--sp)->ia[0]; w2.l; })
|
||||
#define POPD() ({ _Jv_word2 w2; \
|
||||
w2.ia[1] = (--sp)->ia[0]; \
|
||||
w2.ia[0] = (--sp)->ia[0]; w2.d; })
|
||||
|
||||
#define LOADA(I) (sp++)->o = locals[I].o
|
||||
#define LOADI(I) (sp++)->i = locals[I].i
|
||||
|
@ -456,17 +459,6 @@ dump_time ()
|
|||
|
||||
void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
|
||||
{
|
||||
/* for some reason, which I do not understand, the compiler on x86
|
||||
* allocates almost 4k stack space for this function! Even though
|
||||
* there are many local variables, they are all nicely contained
|
||||
* within a block scope, except for the few declared right below
|
||||
* here. What's going on?? It could well be, that there in fact is
|
||||
* on the order of 1000 local variables, including all those inlined
|
||||
* and expanded from macros... Compiling with -O0, it allocates a
|
||||
* "modest" 300 bytes of stack space. Among all those options of
|
||||
* gcc, why isn't there a -fpack-stack, allowing reuse of stack
|
||||
* locations? */
|
||||
|
||||
_Jv_word *sp = inv->sp;
|
||||
unsigned char *pc = inv->pc;
|
||||
_Jv_word *locals = inv->local_base ();
|
||||
|
@ -542,9 +534,6 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
|
|||
#endif
|
||||
opcode = *pc++;
|
||||
|
||||
/* we special-case the single opcode aload_0 -- it makes
|
||||
up 10% of the time spent in the main loop. */
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case op_aload_0: // 0x2a
|
||||
|
@ -1359,63 +1348,63 @@ void _Jv_InterpMethod::continue1 (_Jv_InterpMethodInvocation *inv)
|
|||
goto next_insn;
|
||||
|
||||
case op_i2l:
|
||||
PUSHL ((jlong)POPI ());
|
||||
{jlong value = POPI(); PUSHL (value);}
|
||||
goto next_insn;
|
||||
|
||||
case op_i2f:
|
||||
PUSHF ((jfloat)POPI ());
|
||||
{jfloat value = POPI(); PUSHF (value);}
|
||||
goto next_insn;
|
||||
|
||||
case op_i2d:
|
||||
PUSHD ((jdouble)POPI ());
|
||||
{jdouble value = POPI(); PUSHD (value);}
|
||||
goto next_insn;
|
||||
|
||||
case op_l2i:
|
||||
PUSHI ((jint)POPL ());
|
||||
{jint value = POPL(); PUSHI (value);}
|
||||
goto next_insn;
|
||||
|
||||
case op_l2f:
|
||||
PUSHF ((jfloat)POPL ());
|
||||
{jfloat value = POPL(); PUSHF (value);}
|
||||
goto next_insn;
|
||||
|
||||
case op_l2d:
|
||||
PUSHD ((jdouble)POPL ());
|
||||
{jdouble value = POPL(); PUSHD (value);}
|
||||
goto next_insn;
|
||||
|
||||
case op_f2i:
|
||||
PUSHI ((jint)POPF ());
|
||||
{ jint value = (jint)POPF (); PUSHI(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_f2l:
|
||||
PUSHL ((jlong)POPF ());
|
||||
{ jlong value = (jlong)POPF (); PUSHL(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_f2d:
|
||||
PUSHD ((jdouble)POPF ());
|
||||
{ jdouble value = POPF (); PUSHD(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_d2i:
|
||||
PUSHI ((jint)POPD ());
|
||||
{ jint value = (jint)POPD (); PUSHI(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_d2l:
|
||||
PUSHL ((jlong)POPD ());
|
||||
{ jlong value = (jlong)POPD (); PUSHL(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_d2f:
|
||||
PUSHF ((jfloat)POPD ());
|
||||
{ jfloat value = POPD (); PUSHF(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_i2b:
|
||||
PUSHI ((jbyte)POPI ());
|
||||
{ jbyte value = POPI (); PUSHI(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_i2c:
|
||||
PUSHI ((jchar)POPI ());
|
||||
{ jchar value = POPI (); PUSHI(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_i2s:
|
||||
PUSHI ((jshort)POPI ());
|
||||
{ jshort value = POPI (); PUSHI(value); }
|
||||
goto next_insn;
|
||||
|
||||
case op_lcmp:
|
||||
|
|
|
@ -16,6 +16,7 @@ details. */
|
|||
|
||||
#include <java/lang/Object.h>
|
||||
#include <java/lang/String.h>
|
||||
#include <java/net/URL.h>
|
||||
|
||||
// We declare these here to avoid including cni.h.
|
||||
extern "C" void _Jv_InitClass (jclass klass);
|
||||
|
@ -108,6 +109,7 @@ public:
|
|||
|
||||
jstring getName (void);
|
||||
|
||||
java::net::URL *getResource (jstring resourceName);
|
||||
java::io::InputStream *getResourceAsStream (jstring resourceName);
|
||||
JArray<jobject> *getSigners (void);
|
||||
|
||||
|
@ -182,7 +184,7 @@ private:
|
|||
friend jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
|
||||
java::lang::ClassLoader *loader);
|
||||
|
||||
friend void _Jv_InternClassStrings (jclass);
|
||||
friend void _Jv_PrepareCompiledClass (jclass);
|
||||
|
||||
#ifdef INTERPRETER
|
||||
friend jboolean _Jv_IsInterpretedClass (jclass);
|
||||
|
|
|
@ -80,13 +80,41 @@ public final class Class implements Serializable
|
|||
public native int getModifiers ();
|
||||
public native String getName ();
|
||||
|
||||
// FIXME: can't implement this until we have java.net.
|
||||
// public URL getResource (String resourceName);
|
||||
|
||||
// FIXME: implement.
|
||||
public InputStream getResourceAsStream (String resourceName)
|
||||
public java.net.URL getResource (String resourceName)
|
||||
{
|
||||
return null;
|
||||
String name = resourcePath (resourceName);
|
||||
ClassLoader loader = getClassLoader ();
|
||||
if (loader == null)
|
||||
return ClassLoader.getSystemResource (name);
|
||||
else
|
||||
return loader.getResource (name);
|
||||
}
|
||||
|
||||
public java.io.InputStream getResourceAsStream (String resourceName)
|
||||
{
|
||||
String name = resourcePath (resourceName);
|
||||
ClassLoader loader = getClassLoader ();
|
||||
if (loader == null)
|
||||
return ClassLoader.getSystemResourceAsStream (name);
|
||||
else
|
||||
return loader.getResourceAsStream (name);
|
||||
}
|
||||
|
||||
private String resourcePath (String resourceName)
|
||||
{
|
||||
if (resourceName.startsWith ("/"))
|
||||
return resourceName.substring (1);
|
||||
|
||||
Class c = this;
|
||||
while (c.isArray ())
|
||||
c = c.getComponentType ();
|
||||
|
||||
String packageName = c.getName ().replace ('.', '/');
|
||||
int end = packageName.lastIndexOf ('/');
|
||||
if (end == -1)
|
||||
return resourceName;
|
||||
else
|
||||
return packageName.substring (0, end+1) + resourceName;
|
||||
}
|
||||
|
||||
// FIXME: implement. Requires java.security.
|
||||
|
|
|
@ -26,6 +26,13 @@ import java.util.Stack;
|
|||
public abstract class ClassLoader {
|
||||
|
||||
static private ClassLoader system;
|
||||
private ClassLoader parent;
|
||||
|
||||
public ClassLoader getParent ()
|
||||
{
|
||||
/* FIXME: security */
|
||||
return parent;
|
||||
}
|
||||
|
||||
private static native ClassLoader getVMClassLoader0 ();
|
||||
|
||||
|
@ -36,17 +43,29 @@ public abstract class ClassLoader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>ClassLoader</code>. The only thing this
|
||||
* Creates a <code>ClassLoader</code> with no parent.
|
||||
* @exception java.lang.SecurityException if not allowed
|
||||
*/
|
||||
protected ClassLoader()
|
||||
{
|
||||
this (null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>ClassLoader</code> with the given parent.
|
||||
* The parent may be <code>null</code>.
|
||||
* The only thing this
|
||||
* constructor does, is to call
|
||||
* <code>checkCreateClassLoader</code> on the current
|
||||
* security manager.
|
||||
* @exception java.lang.SecurityException if not allowed
|
||||
*/
|
||||
protected ClassLoader()
|
||||
protected ClassLoader(ClassLoader parent)
|
||||
{
|
||||
SecurityManager security = System.getSecurityManager ();
|
||||
if (security != null)
|
||||
security.checkCreateClassLoader ();
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,22 +78,68 @@ public abstract class ClassLoader {
|
|||
public Class loadClass(String name)
|
||||
throws java.lang.ClassNotFoundException, java.lang.LinkageError
|
||||
{
|
||||
return loadClass (name, true);
|
||||
return loadClass (name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the class by the given name.
|
||||
* As per java 1.1, this has been deprecated. Use
|
||||
* <code>loadClass(String)</code>
|
||||
* instead.
|
||||
* Loads the class by the given name. The default implementation
|
||||
* will search for the class in the following order (similar to jdk 1.2)
|
||||
* <ul>
|
||||
* <li> First <code>findLoadedClass</code>.
|
||||
* <li> If parent is non-null, <code>parent.loadClass</code>;
|
||||
* otherwise <code>findSystemClass</code>.
|
||||
* <li> <code>findClass</code>.
|
||||
* </ul>
|
||||
* If <code>link</code> is true, <code>resolveClass</code> is then
|
||||
* called. <p> Normally, this need not be overridden; override
|
||||
* <code>findClass</code> instead.
|
||||
* @param name the name of the class.
|
||||
* @param link if the class should be linked.
|
||||
* @return the class loaded.
|
||||
* @exception java.lang.ClassNotFoundException
|
||||
* @deprecated
|
||||
*/
|
||||
protected abstract Class loadClass(String name, boolean link)
|
||||
throws java.lang.ClassNotFoundException, java.lang.LinkageError;
|
||||
protected Class loadClass(String name, boolean link)
|
||||
throws java.lang.ClassNotFoundException, java.lang.LinkageError
|
||||
{
|
||||
Class c = findLoadedClass (name);
|
||||
|
||||
if (c == null)
|
||||
{
|
||||
try {
|
||||
if (parent != null)
|
||||
return parent.loadClass (name, link);
|
||||
else
|
||||
c = findSystemClass (name);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
/* ignore, we'll try findClass */;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == null)
|
||||
c = findClass (name);
|
||||
|
||||
if (c == null)
|
||||
throw new ClassNotFoundException (name);
|
||||
|
||||
if (link)
|
||||
resolveClass (c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/** Find a class. This should be overridden by subclasses; the
|
||||
* default implementation throws ClassNotFoundException.
|
||||
*
|
||||
* @param name Name of the class to find.
|
||||
* @return The class found.
|
||||
* @exception java.lang.ClassNotFoundException
|
||||
*/
|
||||
protected Class findClass (String name)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
throw new ClassNotFoundException ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a class, given the class-data. According to the JVM, this
|
||||
|
@ -251,7 +316,7 @@ public abstract class ClassLoader {
|
|||
}
|
||||
|
||||
/** Internal method. Calls _Jv_PrepareClass and
|
||||
* _Jv_InternClassStrings. This is only called from resolveClass. */
|
||||
* _Jv_PrepareCompiledClass. This is only called from resolveClass. */
|
||||
private static native void linkClass0(Class clazz)
|
||||
throws java.lang.LinkageError;
|
||||
|
||||
|
@ -263,15 +328,19 @@ public abstract class ClassLoader {
|
|||
|
||||
/**
|
||||
* Returns a class found in a system-specific way, typically
|
||||
* via the <code>java.class.path</code> system property.
|
||||
* via the <code>java.class.path</code> system property. Loads the
|
||||
* class if necessary.
|
||||
*
|
||||
* @param name the class to resolve.
|
||||
* @return the class loaded.
|
||||
* @exception java.lang.LinkageError
|
||||
* @exception java.lang.ClassNotFoundException
|
||||
*/
|
||||
protected native Class findSystemClass(String name)
|
||||
throws java.lang.ClassNotFoundException, java.lang.LinkageError;
|
||||
protected Class findSystemClass(String name)
|
||||
throws java.lang.ClassNotFoundException, java.lang.LinkageError
|
||||
{
|
||||
return getSystemClassLoader ().loadClass (name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Does currently nothing.
|
||||
|
@ -280,10 +349,11 @@ public abstract class ClassLoader {
|
|||
/* claz.setSigners (signers); */
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* If a class named <code>name</code> was previously loaded using
|
||||
* this <code>ClassLoader</code>, then it is returned. Otherwise
|
||||
* it returns <code>null</code>.
|
||||
* it returns <code>null</code>. (Unlike the JDK this is native,
|
||||
* since we implement the class table internally.)
|
||||
* @param name class to find.
|
||||
* @return the class loaded, or null.
|
||||
*/
|
||||
|
@ -297,10 +367,6 @@ public abstract class ClassLoader {
|
|||
return system.getResource (name);
|
||||
}
|
||||
|
||||
public static final byte[] getSystemResourceAsBytes(String name) {
|
||||
return system.getResourceAsBytes (name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an InputStream representing the resource name.
|
||||
* This is essentially like
|
||||
|
@ -309,7 +375,6 @@ public abstract class ClassLoader {
|
|||
* @param name resource to load
|
||||
* @return an InputStream, or null
|
||||
* @see java.lang.ClassLoader#getResource(String)
|
||||
* @see java.lang.ClassLoader#getResourceAsBytes(String)
|
||||
* @see java.io.InputStream
|
||||
*/
|
||||
public InputStream getResourceAsStream(String name)
|
||||
|
@ -323,42 +388,9 @@ public abstract class ClassLoader {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a byte array <code>byte[]</code> representing the
|
||||
* resouce <code>name</code>. This only works for resources
|
||||
* that have a known <code>content-length</code>, and
|
||||
* it will block while loading the resource. Returns null
|
||||
* for error conditions.<p>
|
||||
* Since it is synchroneous, this is only convenient for
|
||||
* resources that are "readily" available. System resources
|
||||
* can conveniently be loaded this way, and the runtime
|
||||
* system uses this to load class files. <p>
|
||||
* To find the class data for a given class, use
|
||||
* something like the following:
|
||||
* <ul><code>
|
||||
* String res = clazz.getName().replace ('.', '/')) + ".class";<br>
|
||||
* byte[] data = getResourceAsBytes (res);
|
||||
* </code></ul>
|
||||
* @param name resource to load
|
||||
* @return a byte array, or null
|
||||
* @see java.lang.ClassLoader#getResource(String)
|
||||
* @see java.lang.ClassLoader#getResourceAsStream(String)
|
||||
*/
|
||||
public byte[] getResourceAsBytes(String name) {
|
||||
try {
|
||||
URL res = getResource (name);
|
||||
if (res == null) return null;
|
||||
URLConnection conn = res.openConnection ();
|
||||
int len = conn.getContentLength ();
|
||||
if (len == -1) return null;
|
||||
return readbytes (conn.getInputStream (), len);
|
||||
} catch (java.io.IOException x) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an java.io.URL representing the resouce <code>name</code>.
|
||||
* The default implementation just returns <code>null</code>.
|
||||
* @param name resource to load
|
||||
* @return a URL, or null if there is no such resource.
|
||||
* @see java.lang.ClassLoader#getResourceAsBytes(String)
|
||||
|
@ -369,31 +401,5 @@ public abstract class ClassLoader {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility routine to read a resource fully, even if the given
|
||||
* InputStream only provides partial results.
|
||||
*/
|
||||
private static byte[] readbytes (InputStream is, int length)
|
||||
{
|
||||
try {
|
||||
|
||||
byte[] data = new byte[length];
|
||||
int read;
|
||||
int off = 0;
|
||||
|
||||
while (off != length)
|
||||
{
|
||||
read = is.read (data, off, (int) (length-off));
|
||||
|
||||
if (read == -1)
|
||||
return null;
|
||||
|
||||
off += read;
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (java.io.IOException x) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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 java.lang;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import gnu.gcj.util.path.SearchPath;
|
||||
|
||||
final class VMClassLoader extends java.lang.ClassLoader
|
||||
{
|
||||
private SearchPath path;
|
||||
private final String path_seperator;
|
||||
private final String file_seperator;
|
||||
private final char file_seperator_char;
|
||||
|
||||
private VMClassLoader () {
|
||||
path_seperator = System.getProperty ("path.separator", ":");
|
||||
file_seperator = System.getProperty ("file.separator", "/");
|
||||
|
||||
file_seperator_char = file_seperator.charAt (0);
|
||||
|
||||
String class_path = System.getProperty ("java.class.path", ".");
|
||||
path = new SearchPath (class_path);
|
||||
}
|
||||
|
||||
protected Class loadClass(String name,
|
||||
boolean resolve)
|
||||
throws java.lang.ClassNotFoundException, java.lang.LinkageError
|
||||
{
|
||||
return loadClassInternal (name, resolve, false);
|
||||
}
|
||||
|
||||
/** I'm a little in doubt here, if this method is
|
||||
actually supposed to throw a LinkageError, or not.
|
||||
The spec, 20.14.3, is a little unclear. It says:
|
||||
|
||||
`` The general contract of loadClass is that, given the name
|
||||
of a class, it either returns the Class object for the class
|
||||
or throws a ClassNotFoundException.''
|
||||
|
||||
However, by making LinkageError a checked exception,
|
||||
i.e., mention it directly in the throws clause,
|
||||
we'll force caller to consider that case as well.
|
||||
**/
|
||||
|
||||
protected Class loadClassInternal(String name,
|
||||
boolean resolve,
|
||||
boolean fromBootLoader)
|
||||
throws java.lang.ClassNotFoundException, java.lang.LinkageError
|
||||
{
|
||||
Class clazz;
|
||||
|
||||
/** TODO: call _Jv_VerifyClassName **/
|
||||
if ( (name.indexOf ('/') != -1)
|
||||
|| (name.charAt (0) == '.')
|
||||
|| (name.indexOf (file_seperator) != -1)
|
||||
|| (name.indexOf ("..") != -1))
|
||||
{
|
||||
throw new IllegalArgumentException (name);
|
||||
}
|
||||
|
||||
// already loaded?
|
||||
clazz = findLoadedClass (name);
|
||||
|
||||
// we need access to the boot class loader here
|
||||
if (clazz == null && !fromBootLoader)
|
||||
clazz = findBootClass (name);
|
||||
|
||||
if (clazz == null)
|
||||
{
|
||||
StringBuffer res = new StringBuffer ();
|
||||
|
||||
// here we do actually replace .'s with /'s because
|
||||
// we're going to find something in the file system.
|
||||
res.append (name.replace ('.', file_seperator_char));
|
||||
res.append (".class");
|
||||
|
||||
byte[] data = getResourceAsBytes (res.toString ());
|
||||
|
||||
if (data == null)
|
||||
throw new ClassNotFoundException (name);
|
||||
|
||||
clazz = defineClass (name, data, 0, data.length);
|
||||
|
||||
}
|
||||
|
||||
if (resolve && clazz != null)
|
||||
resolveClass (clazz);
|
||||
|
||||
return clazz;
|
||||
}
|
||||
|
||||
private native Class findBootClass (String name);
|
||||
|
||||
public InputStream getResourceAsStream(String name)
|
||||
{
|
||||
return path.getStream (name);
|
||||
}
|
||||
|
||||
public URL getResource(String name)
|
||||
{
|
||||
return path.getURL (name);
|
||||
}
|
||||
|
||||
public byte[] getResourceAsBytes(String name)
|
||||
{
|
||||
return path.getBytes (name);
|
||||
}
|
||||
}
|
|
@ -92,8 +92,6 @@ java::lang::Class::forName (jstring className)
|
|||
if (! klass)
|
||||
JvThrow (new java::lang::ClassNotFoundException (className));
|
||||
|
||||
_Jv_InitClass (klass);
|
||||
|
||||
return klass;
|
||||
}
|
||||
|
||||
|
@ -354,6 +352,8 @@ java::lang::Class::newInstance (void)
|
|||
|| java::lang::reflect::Modifier::isAbstract(accflags))
|
||||
JvThrow (new java::lang::InstantiationException);
|
||||
|
||||
_Jv_InitClass (this);
|
||||
|
||||
_Jv_Method *meth = _Jv_GetMethodLocal (this, init_name, void_signature);
|
||||
if (! meth)
|
||||
JvThrow (new java::lang::NoSuchMethodException);
|
||||
|
@ -408,7 +408,7 @@ java::lang::Class::initializeClass (void)
|
|||
{
|
||||
// Step 1.
|
||||
_Jv_MonitorEnter (this);
|
||||
_Jv_InternClassStrings (this);
|
||||
_Jv_PrepareCompiledClass (this);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -20,8 +20,9 @@ details. */
|
|||
#include <java/lang/Character.h>
|
||||
#include <java/lang/Thread.h>
|
||||
#include <java/lang/ClassLoader.h>
|
||||
#include <java/lang/VMClassLoader.h>
|
||||
#include <gnu/gcj/runtime/VMClassLoader.h>
|
||||
#include <java/lang/InternalError.h>
|
||||
#include <java/lang/IllegalAccessError.h>
|
||||
#include <java/lang/LinkageError.h>
|
||||
#include <java/lang/ClassFormatError.h>
|
||||
#include <java/lang/NoClassDefFoundError.h>
|
||||
|
@ -46,7 +47,7 @@ extern java::lang::Class ClassLoaderClass;
|
|||
/////////// java.lang.ClassLoader native methods ////////////
|
||||
|
||||
#ifdef INTERPRETER
|
||||
java::lang::VMClassLoader *redirect = 0;
|
||||
gnu::gcj::runtime::VMClassLoader *redirect = 0;
|
||||
#endif
|
||||
|
||||
java::lang::ClassLoader*
|
||||
|
@ -54,7 +55,7 @@ java::lang::ClassLoader::getVMClassLoader0 ()
|
|||
{
|
||||
#ifdef INTERPRETER
|
||||
if (redirect == 0)
|
||||
redirect = new java::lang::VMClassLoader;
|
||||
redirect = new gnu::gcj::runtime::VMClassLoader;
|
||||
return redirect;
|
||||
#else
|
||||
return 0;
|
||||
|
@ -144,7 +145,7 @@ _Jv_WaitForState (jclass klass, int state)
|
|||
if (state == JV_STATE_LINKED)
|
||||
{
|
||||
_Jv_MonitorExit (klass);
|
||||
_Jv_InternClassStrings (klass);
|
||||
_Jv_PrepareCompiledClass (klass);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -179,7 +180,7 @@ java::lang::ClassLoader::linkClass0 (java::lang::Class *klass)
|
|||
}
|
||||
#endif
|
||||
|
||||
_Jv_InternClassStrings (klass);
|
||||
_Jv_PrepareCompiledClass (klass);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -193,7 +194,7 @@ java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
|
|||
/** this is the only native method in VMClassLoader, so
|
||||
we define it here. */
|
||||
jclass
|
||||
java::lang::VMClassLoader::findBootClass (jstring name)
|
||||
gnu::gcj::runtime::VMClassLoader::findSystemClass (jstring name)
|
||||
{
|
||||
return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), 0);
|
||||
}
|
||||
|
@ -204,22 +205,27 @@ java::lang::ClassLoader::findLoadedClass (jstring name)
|
|||
return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), this);
|
||||
}
|
||||
|
||||
jclass
|
||||
java::lang::ClassLoader::findSystemClass (jstring name)
|
||||
{
|
||||
return _Jv_FindClass (_Jv_makeUtf8Const (name), 0);
|
||||
}
|
||||
static const int PUBLIC = 0x001;
|
||||
static const int PRIVATE = 0x002;
|
||||
static const int PROTECTED = 0x004;
|
||||
static const int STATIC = 0x008;
|
||||
static const int FINAL = 0x010;
|
||||
static const int SYNCHRONIZED = 0x020;
|
||||
static const int VOLATILE = 0x040;
|
||||
static const int TRANSIENT = 0x080;
|
||||
static const int NATIVE = 0x100;
|
||||
static const int INTERFACE = 0x200;
|
||||
static const int ABSTRACT = 0x400;
|
||||
static const int ALL_FLAGS = 0x7FF;
|
||||
|
||||
|
||||
/* This is the final step of linking, internalizing the constant strings
|
||||
* of a class. This is called for both compiled and interpreted
|
||||
* classes, and it is *only* called from ClassLoader::linkClass0,
|
||||
* which is always in a context where the current thread has a lock on
|
||||
* the class in question. We define it here, and not in resolve.cc, so that
|
||||
* the entire resolve.cc can be #ifdef'ed away when not using the
|
||||
* interpreter. */
|
||||
/** This function does class-preparation for compiled classes.
|
||||
NOTE: This function replicates functionality from
|
||||
_Jv_ResolvePoolEntry, and this is intentional, since that function
|
||||
is
|
||||
*/
|
||||
void
|
||||
_Jv_InternClassStrings(jclass klass)
|
||||
_Jv_PrepareCompiledClass(jclass klass)
|
||||
{
|
||||
if (klass->state >= JV_STATE_LINKED)
|
||||
return;
|
||||
|
@ -228,14 +234,44 @@ _Jv_InternClassStrings(jclass klass)
|
|||
klass->state = JV_STATE_LINKED;
|
||||
|
||||
_Jv_Constants *pool = &klass->constants;
|
||||
for (int i = 1; i < pool->size; ++i)
|
||||
for (int index = 1; index < pool->size; ++index)
|
||||
{
|
||||
if (pool->tags[i] == JV_CONSTANT_String)
|
||||
if (pool->tags[index] == JV_CONSTANT_Class)
|
||||
{
|
||||
_Jv_Utf8Const *name = pool->data[index].utf8;
|
||||
|
||||
jclass found;
|
||||
if (name->data[0] == '[')
|
||||
found = _Jv_FindClassFromSignature (&name->data[0],
|
||||
klass->loader);
|
||||
else
|
||||
found = _Jv_FindClass (name, klass->loader);
|
||||
|
||||
if (! found)
|
||||
{
|
||||
jstring str = _Jv_NewStringUTF (name->data);
|
||||
JvThrow (new java::lang::ClassNotFoundException (str));
|
||||
}
|
||||
|
||||
if ((found->accflags & PUBLIC) == PUBLIC
|
||||
|| (_Jv_ClassNameSamePackage (found->name,
|
||||
klass->name)))
|
||||
{
|
||||
pool->data[index].clazz = found;
|
||||
pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
JvThrow (new java::lang::IllegalAccessError (found->getName()));
|
||||
}
|
||||
}
|
||||
|
||||
else if (pool->tags[index] == JV_CONSTANT_String)
|
||||
{
|
||||
jstring str;
|
||||
str = _Jv_NewStringUtf8Const (pool->data[i].utf8);
|
||||
pool->data[i].string = str;
|
||||
pool->tags[i] |= JV_CONSTANT_ResolvedFlag;
|
||||
str = _Jv_NewStringUtf8Const (pool->data[index].utf8);
|
||||
pool->data[index].o = str;
|
||||
pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,7 +479,7 @@ jclass _Jv_FindClass (_Jv_Utf8Const *name,
|
|||
}
|
||||
|
||||
// Load using the bootstrap loader jmspec 5.3.1
|
||||
klass = redirect -> loadClassInternal (sname, false, true);
|
||||
klass = redirect -> loadClass (sname, false);
|
||||
|
||||
// register that we're an initiating loader
|
||||
if (klass)
|
||||
|
|
301
libjava/java/net/JarURLConnection.java
Normal file
301
libjava/java/net/JarURLConnection.java
Normal file
|
@ -0,0 +1,301 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package java.net;
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.util.jar.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* @author Kresten Krab Thorup <krab@gnu.org>
|
||||
* @date Aug 10, 1999.
|
||||
*/
|
||||
|
||||
|
||||
public abstract class JarURLConnection extends URLConnection
|
||||
{
|
||||
// three different ways to say the same thing
|
||||
private final URL jarFileURL;
|
||||
|
||||
/** The connection to the jar file itself. A JarURLConnection
|
||||
* can represent an entry in a jar file or an entire jar file. In
|
||||
* either case this describes just the jar file itself. */
|
||||
protected URLConnection jarFileURLConnection;
|
||||
|
||||
// If this is a connection to a jar file element this is set, otherwose null.
|
||||
private final String element;
|
||||
|
||||
// Cached JarURLConnection's
|
||||
static Hashtable conn_cache = new Hashtable();
|
||||
|
||||
public URL getJarFileURL ()
|
||||
{
|
||||
return jarFileURL;
|
||||
}
|
||||
|
||||
public String getEntryName ()
|
||||
{
|
||||
return element;
|
||||
}
|
||||
|
||||
public JarURLConnection(URL url)
|
||||
throws MalformedURLException
|
||||
{
|
||||
super(url);
|
||||
|
||||
String spec = url.getFile();
|
||||
int bang = spec.indexOf ("!/", 0);
|
||||
if (bang == -1)
|
||||
throw new MalformedURLException (url + ": No `!/' in spec.");
|
||||
|
||||
// Extact the url for the jar itself.
|
||||
jarFileURL = new URL(spec.substring (0, bang));
|
||||
|
||||
// Get the name of the element, if any.
|
||||
element = (bang+2==spec.length() ? null : spec.substring (bang+2));
|
||||
}
|
||||
|
||||
public synchronized void connect() throws IOException
|
||||
{
|
||||
// Call is ignored if already connected.
|
||||
if (connected)
|
||||
return;
|
||||
|
||||
if (getUseCaches())
|
||||
{
|
||||
jarFileURLConnection = (URLConnection) conn_cache.get (jarFileURL);
|
||||
|
||||
if (jarFileURLConnection == null)
|
||||
{
|
||||
jarFileURLConnection = jarFileURL.openConnection ();
|
||||
jarFileURLConnection.setUseCaches (true);
|
||||
jarFileURLConnection.connect ();
|
||||
conn_cache.put (jarFileURL, jarFileURLConnection);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jarFileURLConnection = jarFileURL.openConnection ();
|
||||
jarFileURLConnection.connect ();
|
||||
}
|
||||
|
||||
connected = true;
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws IOException
|
||||
{
|
||||
if (!connected)
|
||||
connect();
|
||||
|
||||
if (! doInput)
|
||||
throw new ProtocolException("Can't open InputStream if doInput is false");
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
// This is a JarURLConnection for the entire jar file.
|
||||
|
||||
InputStream jar_is = new BufferedInputStream(jarFileURLConnection.getInputStream ());
|
||||
return new JarInputStream(jar_is);
|
||||
}
|
||||
|
||||
// Reaching this point, we're looking for an element of a jar file.
|
||||
|
||||
JarFile jarfile = null;
|
||||
|
||||
try
|
||||
{
|
||||
jarfile = getJarFile ();
|
||||
}
|
||||
catch (java.io.IOException x)
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
if (jarfile != null)
|
||||
{
|
||||
// this is the easy way...
|
||||
return jarfile.getInputStream (jarfile.getEntry (element));
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the jar file is not local, ...
|
||||
JarInputStream zis = new JarInputStream(jarFileURLConnection.getInputStream ());
|
||||
|
||||
// This is hideous, we're doing a linear search...
|
||||
for (ZipEntry ent = zis.getNextEntry ();
|
||||
ent != null;
|
||||
ent = zis.getNextEntry ())
|
||||
{
|
||||
if (element.equals (ent.getName ()))
|
||||
{
|
||||
int size = (int)ent.getSize();
|
||||
byte[] data = new byte[size];
|
||||
zis.read (data, 0, size);
|
||||
return new ByteArrayInputStream (data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public JarEntry getJarEntry (String name)
|
||||
throws java.io.IOException
|
||||
{
|
||||
JarFile jarfile = null;
|
||||
|
||||
if (! doInput)
|
||||
throw new ProtocolException("Can't open JarEntry if doInput is false");
|
||||
|
||||
try
|
||||
{
|
||||
jarfile = getJarFile ();
|
||||
}
|
||||
catch (java.io.IOException x)
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
if (jarfile == null)
|
||||
{
|
||||
JarInputStream zis = new JarInputStream(jarFileURLConnection.getInputStream ());
|
||||
|
||||
// This is hideous, we're doing a linear search for the thing...
|
||||
for (ZipEntry ent = zis.getNextEntry ();
|
||||
ent != null;
|
||||
ent = zis.getNextEntry ())
|
||||
{
|
||||
if (element.equals (ent.getName ()))
|
||||
{
|
||||
return new JarEntry (ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return jarfile.getJarEntry (element);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract JarFile getJarFile() throws java.io.IOException;
|
||||
|
||||
|
||||
// Steal and borrow from protocol/file/Connection.java
|
||||
|
||||
private Hashtable hdrHash = new Hashtable();
|
||||
private Vector hdrVec = new Vector();
|
||||
private boolean gotHeaders = false;
|
||||
|
||||
// Override default method in URLConnection.
|
||||
public String getHeaderField(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
getHeaders();
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (String) hdrHash.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
// Override default method in URLConnection.
|
||||
public String getHeaderField(int n)
|
||||
{
|
||||
try
|
||||
{
|
||||
getHeaders();
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (n < hdrVec.size())
|
||||
return getField((String) hdrVec.elementAt(n));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Override default method in URLConnection.
|
||||
public String getHeaderFieldKey(int n)
|
||||
{
|
||||
try
|
||||
{
|
||||
getHeaders();
|
||||
}
|
||||
catch (IOException x)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (n < hdrVec.size())
|
||||
return getKey((String) hdrVec.elementAt(n));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getKey(String str)
|
||||
{
|
||||
if (str == null)
|
||||
return null;
|
||||
int index = str.indexOf(':');
|
||||
if (index >= 0)
|
||||
return str.substring(0, index);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getField(String str)
|
||||
{
|
||||
if (str == null)
|
||||
return null;
|
||||
int index = str.indexOf(':');
|
||||
if (index >= 0)
|
||||
return str.substring(index + 1).trim();
|
||||
else
|
||||
return str;
|
||||
}
|
||||
|
||||
private void getHeaders() throws IOException
|
||||
{
|
||||
if (gotHeaders)
|
||||
return;
|
||||
gotHeaders = true;
|
||||
|
||||
connect();
|
||||
|
||||
// Yes, it is overkill to use the hash table and vector here since
|
||||
// we're only putting one header in the file, but in case we need
|
||||
// to add others later and for consistency, we'll implement it this way.
|
||||
|
||||
// Add the only header we know about right now: Content-length.
|
||||
long len;
|
||||
|
||||
if (element == null)
|
||||
len = jarFileURLConnection.getContentLength ();
|
||||
else
|
||||
len = getJarEntry (element).getSize ();
|
||||
|
||||
String line = "Content-length: " + len;
|
||||
hdrVec.addElement(line);
|
||||
|
||||
// The key will never be null in this scenario since we build up the
|
||||
// headers ourselves. If we ever rely on getting a header from somewhere
|
||||
// else, then we may have to check if the result of getKey() is null.
|
||||
String key = getKey(line);
|
||||
hdrHash.put(key.toLowerCase(), Long.toString(len));
|
||||
}
|
||||
|
||||
}
|
221
libjava/java/net/URLClassLoader.java
Normal file
221
libjava/java/net/URLClassLoader.java
Normal file
|
@ -0,0 +1,221 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package java.net;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.jar.*;
|
||||
import java.util.Vector;
|
||||
|
||||
public class URLClassLoader extends ClassLoader
|
||||
{
|
||||
// The URLStreamHandlerFactory
|
||||
URLStreamHandlerFactory factory = null;
|
||||
|
||||
// `path' contains simply the URL's we're using for the searching.
|
||||
private Vector path;
|
||||
|
||||
// If path[n] is a zip/jar, then this holds a JarURLConnection for that thing,
|
||||
// otherwise, path[n] is null.
|
||||
private Vector info;
|
||||
|
||||
private URLStreamHandler getHandler0 (String protocol)
|
||||
{
|
||||
if (factory != null)
|
||||
return factory.createURLStreamHandler(protocol);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public URLClassLoader (URL[] urls)
|
||||
{
|
||||
this (urls, null, null);
|
||||
}
|
||||
|
||||
public URLClassLoader (URL[] urls, ClassLoader parent)
|
||||
{
|
||||
this (urls, parent, null);
|
||||
}
|
||||
|
||||
public URLClassLoader (URL[] urls, ClassLoader parent,
|
||||
URLStreamHandlerFactory fac)
|
||||
{
|
||||
super (parent);
|
||||
|
||||
factory = fac;
|
||||
|
||||
if (urls == null || urls.length == 0)
|
||||
{
|
||||
path = new Vector (1);
|
||||
info = new Vector (1);
|
||||
return;
|
||||
}
|
||||
|
||||
path = new Vector (urls.length);
|
||||
info = new Vector (urls.length);
|
||||
|
||||
for (int i = 0; i < urls.length; i++)
|
||||
{
|
||||
URL u = urls[i];
|
||||
|
||||
// If it is a jar url, then we'll search it as is.
|
||||
if (! u.getProtocol ().equals ("jar"))
|
||||
{
|
||||
String f = u.getFile ();
|
||||
|
||||
// If it ends with '/' we'll take it for a directory,
|
||||
// otherwise it's a jar file. This is how JDK 1.2 defines
|
||||
// it, so we will not try to be smart here.
|
||||
if (f.charAt (f.length ()-1) != '/')
|
||||
{
|
||||
try
|
||||
{
|
||||
u = new URL ("jar", "", -1, (u.toExternalForm ())+"!/",
|
||||
getHandler0 ("jar"));
|
||||
}
|
||||
catch (MalformedURLException x)
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
path.insertElementAt (u, i);
|
||||
|
||||
if (u.getProtocol ().equals ("jar"))
|
||||
{
|
||||
JarURLConnection conn = null;
|
||||
try
|
||||
{
|
||||
conn = (JarURLConnection) u.openConnection ();
|
||||
}
|
||||
catch (java.io.IOException x)
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
info.insertElementAt (conn, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.insertElementAt (null, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public URL getResource (String name)
|
||||
{
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
{
|
||||
URL u = (URL)path.elementAt (i);
|
||||
|
||||
try {
|
||||
JarURLConnection conn = (JarURLConnection) info.elementAt (i);
|
||||
|
||||
if (conn != null)
|
||||
{
|
||||
if (conn.getJarEntry (name) != null)
|
||||
return new URL(u, name, getHandler0 (u.getProtocol()));
|
||||
}
|
||||
else
|
||||
{
|
||||
URL p = new URL (u, name, getHandler0 (u.getProtocol()));
|
||||
|
||||
InputStream is = p.openStream();
|
||||
if (is != null)
|
||||
{
|
||||
is.close();
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
// if we get an exception ... try the next path element
|
||||
} catch (IOException x) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** IN jdk 1.2 this method is not overridden, but we gain performance
|
||||
by doing so.
|
||||
*/
|
||||
|
||||
public InputStream getResourceAsStream (String name)
|
||||
{
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
{
|
||||
URL u = (URL)path.elementAt (i);
|
||||
|
||||
try {
|
||||
JarURLConnection conn = (JarURLConnection) info.elementAt (i);
|
||||
|
||||
if (conn != null)
|
||||
{
|
||||
JarFile file = conn.getJarFile ();
|
||||
JarEntry ent = file.getJarEntry (name);
|
||||
if (ent != null)
|
||||
return file.getInputStream(ent);
|
||||
}
|
||||
else
|
||||
{
|
||||
InputStream is = new URL(u, name, getHandler0 (u.getProtocol())).openStream();
|
||||
if (is != null)
|
||||
return is;
|
||||
}
|
||||
|
||||
// if we get an exception ... try the next path element
|
||||
} catch (IOException x) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// and finally, we can implement our class loader functionality.
|
||||
protected Class findClass (String name)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
if (name == null)
|
||||
throw new ClassNotFoundException ("null");
|
||||
|
||||
try
|
||||
{
|
||||
InputStream is = getResourceAsStream (name.replace ('.', '/') + ".class");
|
||||
|
||||
if (is == null)
|
||||
throw new ClassNotFoundException (name);
|
||||
|
||||
// Here we have to rely on available() to provide the length of
|
||||
// the class; which might not be exactly right in some cases...
|
||||
|
||||
int len = is.available ();
|
||||
byte[] data = new byte[len];
|
||||
|
||||
int left = len;
|
||||
int off = 0;
|
||||
while (left > 0)
|
||||
{
|
||||
int c = is.read (data, off, len-off);
|
||||
if (c == -1 || c == 0)
|
||||
throw new InternalError ("premature end of file");
|
||||
left -= c;
|
||||
off += c;
|
||||
}
|
||||
|
||||
return defineClass (name, data, 0, len);
|
||||
}
|
||||
catch (java.io.IOException x)
|
||||
{
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
23
libjava/java/security/SecureClassLoader.java
Normal file
23
libjava/java/security/SecureClassLoader.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* Copyright (C) 1998, 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package java.security;
|
||||
|
||||
public class SecureClassLoader extends ClassLoader
|
||||
{
|
||||
public SecureClassLoader ()
|
||||
{
|
||||
this (null);
|
||||
}
|
||||
|
||||
public SecureClassLoader (ClassLoader parent)
|
||||
{
|
||||
super (parent);
|
||||
}
|
||||
}
|
||||
|
39
libjava/java/util/jar/JarEntry.java
Normal file
39
libjava/java/util/jar/JarEntry.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package java.util.jar;
|
||||
|
||||
import java.util.zip.*;
|
||||
|
||||
/**
|
||||
* Does not implement the security and manifest methods.
|
||||
*
|
||||
* @author Kresten Krab Thorup <krab@gnu.org>
|
||||
* @date August 10, 1999.
|
||||
*/
|
||||
|
||||
public class JarEntry extends ZipEntry
|
||||
{
|
||||
ZipEntry zip;
|
||||
|
||||
public JarEntry (ZipEntry ent)
|
||||
{
|
||||
super (ent);
|
||||
}
|
||||
|
||||
public JarEntry (JarEntry ent)
|
||||
{
|
||||
super (ent);
|
||||
}
|
||||
|
||||
public JarEntry (String name)
|
||||
{
|
||||
super (name);
|
||||
}
|
||||
|
||||
}
|
56
libjava/java/util/jar/JarFile.java
Normal file
56
libjava/java/util/jar/JarFile.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package java.util.jar;
|
||||
|
||||
import java.util.zip.*;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Does not implement any of the security. Just a place holder, so
|
||||
* that I can implement URLClassLoader.
|
||||
*
|
||||
* @author Kresten Krab Thorup <krab@gnu.org>
|
||||
* @date August 10, 1999.
|
||||
*/
|
||||
|
||||
public class JarFile extends ZipFile
|
||||
{
|
||||
private boolean verify;
|
||||
|
||||
public JarFile (String file) throws java.io.IOException
|
||||
{
|
||||
super (file);
|
||||
}
|
||||
|
||||
public JarFile (File file) throws java.io.IOException
|
||||
{
|
||||
super (file);
|
||||
}
|
||||
|
||||
public JarFile (String file, boolean verify) throws java.io.IOException
|
||||
{
|
||||
super (file);
|
||||
this.verify = verify;
|
||||
}
|
||||
|
||||
public JarFile (File file, boolean verify) throws java.io.IOException
|
||||
{
|
||||
super (file);
|
||||
this.verify = verify;
|
||||
}
|
||||
|
||||
public JarEntry getJarEntry (String name)
|
||||
{
|
||||
ZipEntry ent = getEntry(name);
|
||||
if (ent == null)
|
||||
return null;
|
||||
else
|
||||
return new JarEntry(ent);
|
||||
}
|
||||
}
|
32
libjava/java/util/jar/JarInputStream.java
Normal file
32
libjava/java/util/jar/JarInputStream.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* Copyright (C) 1999 Cygnus Solutions
|
||||
|
||||
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. */
|
||||
|
||||
package java.util.jar;
|
||||
|
||||
import java.util.zip.*;
|
||||
|
||||
/**
|
||||
* Does not implement any of the security. Just a place holder, so
|
||||
* that I can implement URLClassLoader.
|
||||
*
|
||||
* @author Kresten Krab Thorup <krab@gnu.org>
|
||||
* @date August 10, 1999.
|
||||
*/
|
||||
|
||||
public class JarInputStream extends ZipInputStream
|
||||
{
|
||||
public JarEntry getNextJarEntry () throws java.io.IOException
|
||||
{
|
||||
return new JarEntry (getNextEntry ());
|
||||
}
|
||||
|
||||
public JarInputStream (java.io.InputStream is)
|
||||
{
|
||||
super(is);
|
||||
}
|
||||
}
|
|
@ -46,6 +46,18 @@ public class ZipEntry implements ZipConstants
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public ZipEntry (ZipEntry ent)
|
||||
{
|
||||
comment = ent.comment;
|
||||
compressedSize = ent.compressedSize;
|
||||
crc = ent.crc;
|
||||
extra = ent.extra;
|
||||
method = ent.method;
|
||||
size = ent.size;
|
||||
time = ent.time;
|
||||
relativeOffset = ent.relativeOffset;
|
||||
}
|
||||
|
||||
public String getComment () { return comment; }
|
||||
|
||||
public long getCompressedSize () { return compressedSize; }
|
||||
|
|
|
@ -22,12 +22,14 @@ public class ZipFile implements ZipConstants
|
|||
{
|
||||
file = new RandomAccessFile(fname, "r");
|
||||
name = fname;
|
||||
readDirectory ();
|
||||
}
|
||||
|
||||
public ZipFile (File f) throws IOException
|
||||
{
|
||||
file = new RandomAccessFile(f, "r");
|
||||
name = f.getName();
|
||||
readDirectory ();
|
||||
}
|
||||
|
||||
void readDirectory () throws IOException
|
||||
|
|
|
@ -611,20 +611,9 @@ JvRunMain (jclass klass, int argc, const char **argv)
|
|||
LTDL_SET_PRELOADED_SYMBOLS ();
|
||||
#endif
|
||||
|
||||
if (klass == NULL)
|
||||
{
|
||||
arg_vec = JvConvertArgv (argc - 2, argv + 2);
|
||||
main_group = new java::lang::ThreadGroup (23);
|
||||
main_thread = new java::lang::FirstThread (main_group,
|
||||
JvNewStringLatin1 (argv[1]),
|
||||
arg_vec);
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_vec = JvConvertArgv (argc - 1, argv + 1);
|
||||
main_group = new java::lang::ThreadGroup (23);
|
||||
main_thread = new java::lang::FirstThread (main_group, klass, arg_vec);
|
||||
}
|
||||
arg_vec = JvConvertArgv (argc - 1, argv + 1);
|
||||
main_group = new java::lang::ThreadGroup (23);
|
||||
main_thread = new java::lang::FirstThread (main_group, klass, arg_vec);
|
||||
|
||||
main_thread->start();
|
||||
_Jv_ThreadWait ();
|
||||
|
@ -632,6 +621,34 @@ JvRunMain (jclass klass, int argc, const char **argv)
|
|||
java::lang::Runtime::getRuntime ()->exit (0);
|
||||
}
|
||||
|
||||
void
|
||||
_Jv_RunMain (const char *class_name, int argc, const char **argv)
|
||||
{
|
||||
INIT_SEGV;
|
||||
#ifdef HANDLE_FPE
|
||||
INIT_FPE;
|
||||
#else
|
||||
arithexception = new java::lang::ArithmeticException
|
||||
(JvNewStringLatin1 ("/ by zero"));
|
||||
#endif
|
||||
|
||||
no_memory = new java::lang::OutOfMemoryError;
|
||||
|
||||
#ifdef USE_LTDL
|
||||
LTDL_SET_PRELOADED_SYMBOLS ();
|
||||
#endif
|
||||
|
||||
arg_vec = JvConvertArgv (argc - 1, argv + 1);
|
||||
main_group = new java::lang::ThreadGroup (23);
|
||||
main_thread = new java::lang::FirstThread (main_group,
|
||||
JvNewStringLatin1 (class_name),
|
||||
arg_vec);
|
||||
main_thread->start();
|
||||
_Jv_ThreadWait ();
|
||||
|
||||
java::lang::Runtime::getRuntime ()->exit (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ details. */
|
|||
|
||||
#include <java-interp.h>
|
||||
|
||||
#ifdef INTERPRETER
|
||||
|
||||
#include <cni.h>
|
||||
#include <jvm.h>
|
||||
#include <string.h>
|
||||
|
@ -30,6 +28,8 @@ details. */
|
|||
#include <java/lang/ClassNotFoundException.h>
|
||||
#include <java/lang/IncompatibleClassChangeError.h>
|
||||
|
||||
#ifdef INTERPRETER
|
||||
|
||||
static void throw_internal_error (char *msg)
|
||||
__attribute__ ((__noreturn__));
|
||||
static void throw_class_format_error (jstring msg)
|
||||
|
@ -124,6 +124,7 @@ _Jv_ResolvePoolEntry (jclass klass, int index)
|
|||
}
|
||||
break;
|
||||
|
||||
|
||||
case JV_CONSTANT_Fieldref:
|
||||
{
|
||||
_Jv_ushort class_index, name_and_type_index;
|
||||
|
@ -316,6 +317,7 @@ _Jv_ResolvePoolEntry (jclass klass, int index)
|
|||
return pool->data[index];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_Jv_ResolveField (_Jv_Field *field, java::lang::ClassLoader *loader)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
# Makefile.in generated automatically by automake 1.4a from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
|
@ -10,7 +10,6 @@
|
|||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
|
@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@
|
|||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_FLAG =
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
|
@ -108,6 +108,7 @@ ZLIBSPEC = @ZLIBSPEC@
|
|||
here = @here@
|
||||
libgcj_basedir = @libgcj_basedir@
|
||||
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign dejagnu no-installinfo
|
||||
|
||||
# Setup the testing framework, if you have one
|
||||
|
@ -122,15 +123,16 @@ RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
|
|||
|
||||
|
||||
RUNTESTFLAGS = @AM_RUNTESTFLAGS@
|
||||
subdir = testsuite
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
|
||||
CONFIG_HEADER = ../include/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_SOURCES =
|
||||
DIST_COMMON = ChangeLog Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
|
@ -147,8 +149,6 @@ TAGS:
|
|||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = testsuite
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
|
@ -158,7 +158,7 @@ distdir: $(DISTFILES)
|
|||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|
@ -222,7 +222,7 @@ uninstall: uninstall-am
|
|||
all-am: Makefile
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
|
@ -257,8 +257,8 @@ maintainer-clean: maintainer-clean-am
|
|||
.PHONY: tags distdir check-DEJAGNU info-am info dvi-am dvi check \
|
||||
check-am installcheck-am installcheck install-info-am install-info \
|
||||
install-exec-am install-exec install-data-am install-data install-am \
|
||||
install uninstall-am uninstall all-redirect all-am all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
install uninstall-am uninstall all-redirect all-am all install-strip \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue