I've attached an updated patch for this. There was a problem with the
last patch that broke gij's -D handling: _Jv_Compiler_Properties was
initialized to NULL at the start of _Jv_CreateJavaVM. I've added a new
variable _Jv_Properties_Count so that _Jv_Compiler_Properties can always
be allocated dynamically. "make check" didn't catch the gij -D
breakage; we should probably add a test for this.
I tested this new patch with "make check" -- it introduces one new pass
and no new failures.
Tom
2005-02-20 Thomas Fitzsimmons <fitzsim@redhat.com>
* gij.cc (main): Remove last_D_option. Dynamically allocate
_Jv_Compiler_Properties.
* jni.cc (JNI_CreateJavaVM): Pass args to _Jv_CreateJavaVM. Move
argument parsing code ...
* prims.cc (_Jv_CreateJavaVM): ... here.
(_Jv_Compiler_Properties): Initialize to NULL.
(_Jv_Properties_Count): Initialize to 0.
* include/java-props.h (_Jv_Properties_Count): Declare.
* java/lang/natRuntime.cc (insertSystemProperties): Use
_Jv_Properties_Count in for loop exit condition.
* testsuite/libjava.jni/jni.exp
(gcj_invocation_compile_c_to_binary): New procedure.
(gcj_invocation_test_one): Likewise.
(gcj_jni_run): Run JNI invocation API tests.
* testsuite/libjava.jni/invocation/PR16923.c,
testsuite/libjava.jni/invocation/PR16923.java,
testsuite/libjava.jni/invocation/PR16923.out: New test.
------------------------------------------------------------------------
Index: gij.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gij.cc,v
retrieving revision 1.25
diff -u -r1.25 gij.cc
--- gij.cc 18 Feb 2005 20:52:14 -0000 1.25
+++ gij.cc 20 Feb 2005 07:52:42 -0000
@@ -57,7 +57,6 @@
{
/* We rearrange ARGV so that all the -D options appear near the
beginning. */
- int last_D_option = 0;
bool jar_mode = false;
int i;
@@ -77,7 +76,12 @@
if (! strncmp (arg, "-D", 2))
{
- argv[last_D_option++] = arg + 2;
+ _Jv_Compiler_Properties = (const char**) realloc
+ (_Jv_Compiler_Properties,
+ (_Jv_Properties_Count + 1) * sizeof (char*));
+
+ _Jv_Compiler_Properties[_Jv_Properties_Count++] = strdup (arg + 2);
+
continue;
}
Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.103
diff -u -r1.103 prims.cc
--- prims.cc 16 Feb 2005 04:16:06 -0000 1.103
+++ prims.cc 20 Feb 2005 07:52:44 -0000
@@ -80,10 +80,9 @@
// functions are changed to take a size_t argument instead of jint.
#define MAX_OBJECT_SIZE ((1<<31) - 1)
-static const char *no_properties[] = { NULL };
-
// Properties set at compile time.
-const char **_Jv_Compiler_Properties = no_properties;
+const char **_Jv_Compiler_Properties = NULL;
+int _Jv_Properties_Count = 0;
// The JAR file to add to the beginning of java.class.path.
const char *_Jv_Jar_Class_Path;
@@ -910,15 +909,78 @@
}
jint
-_Jv_CreateJavaVM (void* /*vm_args*/)
+_Jv_CreateJavaVM (void* vm_args)
{
using namespace gcj;
-
+
if (runtimeInitialized)
return -1;
runtimeInitialized = true;
+ // Parse the arguments.
+ if (vm_args != NULL)
+ {