Patch: Method.invoke -vs- null
Tom Tromey
tromey@cygnus.com
Wed Sep 6 14:20:00 GMT 2000
The JDK accepts a null `args' parameter for Method.invoke and
Constructor.newInstance if the underlying method or constructor takes
no arguments. This patch makes libgcj compatible.
2000-09-06 Tom Tromey <tromey@cygnus.com>
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Accept null
`args' if method takes no parameters.
Tom
Index: java/lang/reflect/natMethod.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/reflect/natMethod.cc,v
retrieving revision 1.14
diff -u -r1.14 natMethod.cc
--- natMethod.cc 2000/08/08 03:34:51 1.14
+++ natMethod.cc 2000/09/06 21:16:03
@@ -447,13 +447,17 @@
{
// FIXME: access checks.
- if (parameter_types->length != args->length)
+ if (parameter_types->length == 0 && args == NULL)
+ {
+ // The JDK accepts this, so we do too.
+ }
+ else if (parameter_types->length != args->length)
JvThrow (new java::lang::IllegalArgumentException);
int param_count = parameter_types->length;
jclass *paramelts = elements (parameter_types);
- jobject *argelts = elements (args);
+ jobject *argelts = args == NULL ? NULL : elements (args);
jvalue argvals[param_count];
#define COPY(Where, What, Type) \
More information about the Java-patches
mailing list