This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
-classpath support for gij (now with attachment)
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 7 Jun 2002 12:48:20 +0200
- Subject: -classpath support for gij (now with attachment)
hello list,
I've written a patch for gij (3.2 branch cvs) to make it aware of -classpath.
Please review this patch.
Regards
Michael
Index: gij.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/gij.cc,v
retrieving revision 1.18
diff -u -b -r1.18 gij.cc
--- gij.cc 27 Feb 2002 05:32:13 -0000 1.18
+++ gij.cc 7 Jun 2002 10:35:57 -0000
@@ -93,9 +93,11 @@
version ();
/* FIXME: use getopt and avoid the ugliness here.
We at least need to handle the argument in a better way. */
- else if (! strncmp (arg, "-ms=", 4))
- _Jv_SetInitialHeapSize (arg + 4);
- else if (! strcmp (arg, "-ms"))
+ else if (! strncmp (arg, "-classpath=", 11))
+ _Jv_SetClassPath (arg + 11);
+ else if (! strncmp (arg, "-cp=", 4))
+ _Jv_SetClassPath (arg + 4);
+ else if (! strcmp (arg, "-classpath") || ! strcmp (arg, "-cp"))
{
if (i >= argc - 1)
{
@@ -105,6 +107,14 @@
fprintf (stderr, "Try `gij --help' for more information.\n");
exit (1);
}
+ _Jv_SetClassPath (argv[++i]);
+ }
+ else if (! strncmp (arg, "-ms=", 4))
+ _Jv_SetInitialHeapSize (arg + 4);
+ else if (! strcmp (arg, "-ms"))
+ {
+ if (i >= argc - 1)
+ goto no_arg;
_Jv_SetInitialHeapSize (argv[++i]);
}
else if (! strncmp (arg, "-mx=", 4))
Index: prims.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.72
diff -u -b -r1.72 prims.cc
--- prims.cc 10 Mar 2002 03:53:12 -0000 1.72
+++ prims.cc 7 Jun 2002 10:35:57 -0000
@@ -80,6 +80,9 @@
// The JAR file to add to the beginning of java.class.path.
const char *_Jv_Jar_Class_Path;
+// Classpath from command line to add to java.class.path.
+const char *_Jv_Additional_Class_Path;
+
#ifndef DISABLE_GETENV_PROPERTIES
// Property key/value pairs.
property_pair *_Jv_Environment_Properties;
@@ -1035,6 +1038,13 @@
return (size_t) val;
}
+// Set the Classpath to search for class.
+void
+_Jv_SetClassPath (const char *arg)
+{
+ _Jv_Additional_Class_Path = arg;
+}
+
// Set the initial heap size. This might be ignored by the GC layer.
// This must be called before _Jv_RunMain.
void
Index: include/java-props.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/include/java-props.h,v
retrieving revision 1.7
diff -u -b -r1.7 java-props.h
--- include/java-props.h 21 Aug 2000 06:05:19 -0000 1.7
+++ include/java-props.h 7 Jun 2002 10:35:57 -0000
@@ -25,6 +25,9 @@
// The JAR file to add to the beginning of java.class.path.
extern const char *_Jv_Jar_Class_Path;
+// The classpath to search for classes
+extern const char *_Jv_Additional_Class_Path;
+
// Properties taken from the user's environment.
extern property_pair *_Jv_Environment_Properties;
Index: include/jvm.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/include/jvm.h,v
retrieving revision 1.51
diff -u -b -r1.51 jvm.h
--- include/jvm.h 11 Apr 2002 15:57:56 -0000 1.51
+++ include/jvm.h 7 Jun 2002 10:35:57 -0000
@@ -216,6 +216,9 @@
before _Jv_InitGC. Not required to have any actual effect. */
void _Jv_GCSetMaximumHeapSize (size_t size);
+/* External interface to set the classpath to search for classes. */
+void _Jv_SetClassPath (const char *arg);
+
/* External interface to setting the heap size. Parses ARG (a number
which can optionally have "k" or "m" appended and calls
_Jv_GCSetInitialHeapSize. */
Index: java/lang/natRuntime.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/lang/natRuntime.cc,v
retrieving revision 1.23
diff -u -b -r1.23 natRuntime.cc
--- java/lang/natRuntime.cc 14 May 2002 05:29:30 -0000 1.23
+++ java/lang/natRuntime.cc 7 Jun 2002 10:35:58 -0000
@@ -510,7 +510,13 @@
else
{
// FIXME: find libgcj.zip and append its path?
- char *classpath = ::getenv("CLASSPATH");
+ const char *classpath;
+
+ if (_Jv_Additional_Class_Path)
+ classpath = _Jv_Additional_Class_Path;
+ else
+ classpath = ::getenv("CLASSPATH");
+
jstring cp = newprops->getProperty (JvNewStringLatin1("java.class.path"));
java::lang::StringBuffer *sb = new java::lang::StringBuffer ();