This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: Method.invoke and class init.
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 27 Aug 2002 17:52:37 -0600
- Subject: Patch: FYI: Method.invoke and class init.
- Reply-to: tromey at redhat dot com
I'm checking this in.
Method.invoke and Constructor.newInstance need to initialize the class
before invoking the underlying method. This patch implements that.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/reflect/natConstructor.cc (newInstance): Initialize
class.
* java/lang/reflect/natMethod.cc (invoke): Initialize class.
Index: java/lang/reflect/natConstructor.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/reflect/natConstructor.cc,v
retrieving revision 1.7
diff -u -r1.7 natConstructor.cc
--- java/lang/reflect/natConstructor.cc 26 Mar 2001 07:05:32 -0000 1.7
+++ java/lang/reflect/natConstructor.cc 27 Aug 2002 23:55:15 -0000
@@ -1,6 +1,6 @@
// natConstructor.cc - Native code for Constructor class.
-/* Copyright (C) 1999, 2000, 2001 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
This file is part of libgcj.
@@ -49,6 +49,8 @@
using namespace java::lang::reflect;
if (Modifier::isAbstract (declaringClass->getModifiers()))
throw new InstantiationException;
+
+ _Jv_InitClass (declaringClass);
jmethodID meth = _Jv_FromReflectedConstructor (this);
// In the constructor case the return type is the type of the
Index: java/lang/reflect/natMethod.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/reflect/natMethod.cc,v
retrieving revision 1.28
diff -u -r1.28 natMethod.cc
--- java/lang/reflect/natMethod.cc 25 Jun 2002 05:29:21 -0000 1.28
+++ java/lang/reflect/natMethod.cc 27 Aug 2002 23:55:15 -0000
@@ -156,6 +156,13 @@
// of the object.
meth = _Jv_LookupDeclaredMethod (k, meth->name, meth->signature);
}
+ else
+ {
+ // We have to initialize a static class. It is safe to do this
+ // here and not in _Jv_CallAnyMethodA because JNI initializes a
+ // class whenever a method lookup is done.
+ _Jv_InitClass (declaringClass);
+ }
return _Jv_CallAnyMethodA (obj, return_type, meth, false,
parameter_types, args);
@@ -404,8 +411,6 @@
memcpy (p, &args[arg], tsize);
p += tsize;
}
-
- // FIXME: initialize class here.
using namespace java::lang;
using namespace java::lang::reflect;