This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
Patch: Method.invoke -vs- null
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: Method.invoke -vs- null
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 06 Sep 2000 15:26:00 -0600
- Reply-To: tromey at cygnus dot com
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) \