Makefile.in: Rebuilt.

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
This commit is contained in:
Anthony Green 2000-08-26 19:25:13 +00:00 committed by Anthony Green
parent 14fdf4b67e
commit 6aaeb97551
10 changed files with 102 additions and 80 deletions

View File

@ -1,3 +1,22 @@
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.
2000-08-23 Mark Wielaard <mark@klomp.org>
* java/util/zip/InflaterInputStream.java (read(byte[],int,int)):

View File

@ -225,6 +225,7 @@ $(nat_headers): libgcj.zip
java/lang/ClassLoader.h: java/lang/ClassLoader.class libgcj.zip
$(GCJH) -classpath $(top_builddir) \
-friend 'jclass _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader);' \
-friend 'void _Jv_RunMain (const char *name, int argc, const char **argv, bool is_jar);' \
$(basename $<)
## Our internal main program needs to be able to create a FirstThread.

View File

@ -115,48 +115,31 @@ here = @here@
libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign no-installinfo
@TESTSUBDIR_TRUE@SUBDIRS = \
@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = \
@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = \
@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = \
@USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = \
@USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias)
toolexeclib_LTLIBRARIES = libgcj.la
toolexeclib_DATA = libgcj.spec
data_DATA = libgcj.zip
@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = \
@NEEDS_DATA_START_TRUE@libgcjdata.a
@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = \
@NEEDS_DATA_START_TRUE@libgcjdata.c
@NEEDS_DATA_START_TRUE@toolexeclib_LIBRARIES = @NEEDS_DATA_START_TRUE@libgcjdata.a
@NEEDS_DATA_START_TRUE@libgcjdata_a_SOURCES = @NEEDS_DATA_START_TRUE@libgcjdata.c
@NATIVE_TRUE@bin_PROGRAMS = \
@NATIVE_TRUE@jv-convert gij
@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij
bin_SCRIPTS = addr2name.awk
@CANADIAN_TRUE@@NULL_TARGET_TRUE@GCJ = \
@CANADIAN_TRUE@@NULL_TARGET_TRUE@gcj
@CANADIAN_TRUE@@NULL_TARGET_FALSE@GCJ = \
@CANADIAN_TRUE@@NULL_TARGET_FALSE@$(target_alias)-gcj
@CANADIAN_FALSE@GCJ = \
@CANADIAN_FALSE@$(expanded)/gcj$(EXEEXT) -B$(expanded)/
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = \
@CANADIAN_TRUE@@NULL_TARGET_FALSE@zip
@CANADIAN_FALSE@ZIP = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@GCJH = \
@CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = \
@CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
@CANADIAN_FALSE@expanded = \
@CANADIAN_FALSE@`cd $(MULTIBUILDTOP)../$(COMPPATH)/gcc && pwd`
@CANADIAN_TRUE@@NULL_TARGET_TRUE@GCJ = @CANADIAN_TRUE@@NULL_TARGET_TRUE@gcj
@CANADIAN_TRUE@@NULL_TARGET_FALSE@GCJ = @CANADIAN_TRUE@@NULL_TARGET_FALSE@$(target_alias)-gcj
@CANADIAN_FALSE@GCJ = @CANADIAN_FALSE@$(expanded)/gcj$(EXEEXT) -B$(expanded)/
@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@zip
@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh
@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
@CANADIAN_FALSE@expanded = @CANADIAN_FALSE@`cd $(MULTIBUILDTOP)../$(COMPPATH)/gcc && pwd`
GCJCOMPILE = CLASSPATH=$(here) $(LIBTOOL) --mode=compile $(GCJ) -fassume-compiled -L$(here) $(JC1FLAGS) -c
GCJLINK = $(LIBTOOL) --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
@ -170,10 +153,8 @@ WARNINGS = -W -Wall
AM_CXXFLAGS = -fno-rtti -fvtable-thunks -fasynchronous-exceptions \
@LIBGCJ_CXXFLAGS@ @EXCEPTIONSPEC@ $(WARNINGS) -D_GNU_SOURCE
@USING_GCC_TRUE@AM_CFLAGS = \
@USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = \
@USING_GCC_FALSE@@LIBGCJ_CFLAGS@
@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS)
@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@
JCFLAGS = -g
JC1FLAGS = -g @LIBGCJ_JAVAFLAGS@
@ -225,8 +206,7 @@ extra_headers = java/lang/Object.h java/lang/Class.h
NM = nm
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS
CONVERT_DIR = gnu/gcj/convert
@ -1045,7 +1025,7 @@ libgcj-test.spec.in libgcj.spec.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
DIST_SUBDIRS = @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
@ -1854,7 +1834,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 \
@ -2088,6 +2068,7 @@ $(nat_headers): libgcj.zip
java/lang/ClassLoader.h: java/lang/ClassLoader.class libgcj.zip
$(GCJH) -classpath $(top_builddir) \
-friend 'jclass _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader);' \
-friend 'void _Jv_RunMain (const char *name, int argc, const char **argv, bool is_jar);' \
$(basename $<)
gnu/gcj/runtime/FirstThread.h: gnu/gcj/runtime/FirstThread.class libgcj.zip

View File

@ -129,7 +129,7 @@ DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
@ -198,7 +198,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 \

View File

@ -55,11 +55,15 @@ final class FirstThread extends Thread
jarMainClassName = a.getValue(Attributes.Name.MAIN_CLASS);
if (jarMainClassName != null)
return;
} catch (Exception e) {
System.err.println ("Failed to load Main-Class manifest attribute from\n" + args[0]);
// empty
}
System.err.println ("Failed to load Main-Class manifest attribute from\n"
+ args[0]);
}
// If interpreter is invoked with -jar, the main class name is recorded

View File

@ -34,7 +34,16 @@ final class VMClassLoader extends java.net.URLClassLoader
try
{
if (e.endsWith(".jar") || e.endsWith (".zip"))
p.addElement(new URL("jar", "", -1, "file:///"+e+"!/"));
{
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 ())

View File

@ -128,7 +128,7 @@ DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
@ -225,7 +225,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 \

View File

@ -348,34 +348,31 @@ java::lang::System::init_properties (void)
}
}
// FIXME: find libgcj.zip and append its path?
char *classpath = ::getenv("CLASSPATH");
jstring cp = properties->getProperty (JvNewStringLatin1("java.class.path"));
java::lang::StringBuffer *sb = new java::lang::StringBuffer ();
if (_Jv_Jar_Class_Path)
{
sb->append (JvNewStringLatin1 (_Jv_Jar_Class_Path));
#ifdef WIN32
sb->append ((jchar) ';');
#else
sb->append ((jchar) ':');
#endif;
}
if (classpath)
{
sb->append (JvNewStringLatin1 (classpath));
#ifdef WIN32
sb->append ((jchar) ';');
#else
sb->append ((jchar) ':');
#endif;
}
if (cp != NULL)
sb->append (cp);
properties->put(JvNewStringLatin1 ("java.class.path"),
JvNewStringLatin1 (_Jv_Jar_Class_Path));
else
sb->append ((jchar) '.');
properties->put(JvNewStringLatin1 ("java.class.path"),
sb->toString ());
{
// FIXME: find libgcj.zip and append its path?
char *classpath = ::getenv("CLASSPATH");
jstring cp = properties->getProperty (JvNewStringLatin1("java.class.path"));
java::lang::StringBuffer *sb = new java::lang::StringBuffer ();
if (classpath)
{
sb->append (JvNewStringLatin1 (classpath));
#ifdef WIN32
sb->append ((jchar) ';');
#else
sb->append ((jchar) ':');
#endif;
}
if (cp != NULL)
sb->append (cp);
else
sb->append ((jchar) '.');
properties->put(JvNewStringLatin1 ("java.class.path"),
sb->toString ());
}
}

View File

@ -47,6 +47,7 @@ details. */
#endif // DISABLE_GETENV_PROPERTIES
#include <java/lang/Class.h>
#include <java/lang/ClassLoader.h>
#include <java/lang/Runtime.h>
#include <java/lang/String.h>
#include <java/lang/Thread.h>
@ -906,6 +907,9 @@ _Jv_RunMain (const char *name, int argc, const char **argv, bool is_jar)
if (is_jar)
{
// name specifies a jar file. We must now extract the
// Main-Class attribute from the jar's manifest file. This is
// done by gnu.gcj.runtime.FirstThread.main.
_Jv_Jar_Class_Path = strdup (name);
arg_vec = JvConvertArgv (1, &_Jv_Jar_Class_Path);
@ -915,7 +919,14 @@ _Jv_RunMain (const char *name, int argc, const char **argv, bool is_jar)
main_thread->start();
_Jv_ThreadWait ();
// FirstThread.main extracts the main class name and stores it
// here.
class_name = gnu::gcj::runtime::FirstThread::jarMainClassName;
// We need a new ClassLoader because the classpath must be the
// jar file only. The easiest way to do this is to lose our
// reference to the previous classloader.
java::lang::ClassLoader::system = NULL;
}
else
class_name = JvNewStringLatin1 (name);

View File

@ -137,7 +137,7 @@ DIST_COMMON = ChangeLog Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
@ -165,7 +165,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 \