This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[RFA/JDWP] Fix VMVirtualMachine.getAllClassMethods
- From: Kyle Galloway <kgallowa at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: Thu, 03 May 2007 14:41:35 -0400
- Subject: [RFA/JDWP] Fix VMVirtualMachine.getAllClassMethods
Currently, if the debugger requests the methods for a class that is part
of the class libraries (or other compiled classes), the
_Jv_FindInterpredClass call it makes returns null, this pointer is then
dereferenced causing the communication thread to crash and the VM to
stop responding to debugger commands. This patch fixes this by using
JVMTI to get the class methods, which will work in both cases. This
effectively makes the getAllClassMethods/getClassMethod pair work like
the getFrames/getFrame pair with the single method being used as a
factory to create objects for the other.
ChangeLog
2007-05-03 Kyle Galloway <kgallowa@redhat.com>
* gnu/classpath/jdwp/natVMVirtualMachine.cc (getClassMethod): Change
to use JVMTI.
Questions/comments/concerns?
Thanks,
Kyle
Index: gnu/classpath/jdwp/natVMVirtualMachine.cc
===================================================================
--- gnu/classpath/jdwp/natVMVirtualMachine.cc (revision 124356)
+++ gnu/classpath/jdwp/natVMVirtualMachine.cc (working copy)
@@ -505,12 +505,25 @@
gnu::classpath::jdwp::VMVirtualMachine::
getClassMethod (jclass klass, jlong id)
{
- jmethodID method = reinterpret_cast<jmethodID> (id);
- _Jv_MethodBase *bmeth = _Jv_FindInterpreterMethod (klass, method);
- if (bmeth != NULL)
- return new gnu::classpath::jdwp::VMMethod (klass, id);
+ jint count;
+ jmethodID *methods;
+ jvmtiError err = _jdwp_jvmtiEnv->GetClassMethods (klass, &count, &methods);
+ if (err != JVMTI_ERROR_NONE)
+ throw_jvmti_error (err);
- throw new gnu::classpath::jdwp::exception::InvalidMethodException (id);
+ jmethodID meth_id = reinterpret_cast<jmethodID> (id);
+
+ using namespace gnu::classpath::jdwp;
+
+ // Check if this method is defined for the given class and if so return a
+ // VMMethod representing it.
+ for (int i = 0; i < count; i++)
+ {
+ if (methods[i] == meth_id)
+ return new VMMethod (klass, reinterpret_cast<jlong> (meth_id));
+ }
+
+ throw new exception::InvalidMethodException (id);
}
java::util::ArrayList *