This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[RFA/JDWP] Implement more VMMethod methods
- From: Keith Seitz <keiths at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: Thu, 25 Jan 2007 11:16:00 -0800
- Subject: [RFA/JDWP] Implement more VMMethod methods
Hi,
The attach patch implements most of the remaining VMMethod methods:
getName, getSignature, and getModifiers. While this should probably have
been three patches, the code is almost identical in each case, so I'm
submitting them all as one patch. [That leaves getVariableTable, which
Kyle Galloway is working on, I believe.]
One question, though, [since I still don't have my cygwin/mingw builds
working], does the natVMVirtualMachine.cc change require a JNICALL?
I know I've used an evil "extern" declaration in natVMMethod.cc, but
adding the ONE function to a header file seems extreme, since this is
the only place it'll ever be used, but, of course, it's the maintainers'
call.
Other than that, it's pretty straightforward: call JVMTI to get the
information, and then copy or massage the result for the JDWP code.
Keith
2007-01-25 Keith Seitz <keiths@redhat.com>
* gnu/classpath/jdwp/natVMVirtualMachine.cc
(_Jv_GetJDWP_JVMTIEnv): New function.
* gnu/classpath/jdwp/natVMMethod.cc (getName): Implement.
(getSignature): Implement.
(getModifiers): Implement.
Index: gnu/classpath/jdwp/natVMVirtualMachine.cc
===================================================================
--- gnu/classpath/jdwp/natVMVirtualMachine.cc (revision 121142)
+++ gnu/classpath/jdwp/natVMVirtualMachine.cc (working copy)
@@ -48,6 +48,12 @@
// JVMTI environment
static jvmtiEnv *_jdwp_jvmtiEnv;
+jvmtiEnv *
+_Jv_GetJDWP_JVMTIEnv (void)
+{
+ return _jdwp_jvmtiEnv;
+}
+
void
gnu::classpath::jdwp::VMVirtualMachine::initialize ()
{
Index: gnu/classpath/jdwp/natVMMethod.cc
===================================================================
--- gnu/classpath/jdwp/natVMMethod.cc (revision 121081)
+++ gnu/classpath/jdwp/natVMMethod.cc (working copy)
@@ -1,6 +1,6 @@
// natVMMethod.cc -- native support for VMMethod
-/* Copyright (C) 2006 Free Software Foundation
+/* Copyright (C) 2006, 2007 Free Software Foundation
This file is part of libgcj.
@@ -11,28 +11,48 @@
#include <config.h>
#include <gcj/cni.h>
#include <java-interp.h>
+#include <jvmti.h>
#include <gnu/classpath/jdwp/VMMethod.h>
#include <gnu/classpath/jdwp/exception/JdwpInternalErrorException.h>
#include <gnu/classpath/jdwp/util/LineTable.h>
#include <gnu/classpath/jdwp/util/VariableTable.h>
-java::lang::String*
+// From natVMVirtualMachine.cc
+extern jvmtiEnv *_Jv_GetJDWP_JVMTIEnv (void);
+
+jstring
gnu::classpath::jdwp::VMMethod::getName ()
{
- return NULL;
+ jvmtiEnv *env = _Jv_GetJDWP_JVMTIEnv ();
+ jmethodID method = reinterpret_cast<jmethodID> (_methodId);
+ char *name;
+ env->GetMethodName (method, &name, NULL, NULL);
+ jstring string = JvNewStringUTF (name);
+ env->Deallocate (reinterpret_cast<unsigned char *> (name));
+ return string;
}
-java::lang::String*
+jstring
gnu::classpath::jdwp::VMMethod::getSignature ()
{
- return NULL;
+ jvmtiEnv *env = _Jv_GetJDWP_JVMTIEnv ();
+ jmethodID method = reinterpret_cast<jmethodID> (_methodId);
+ char *signature;
+ env->GetMethodName (method, NULL, &signature, NULL);
+ jstring string = JvNewStringUTF (signature);
+ env->Deallocate (reinterpret_cast<unsigned char *> (signature));
+ return string;
}
jint
gnu::classpath::jdwp::VMMethod::getModifiers ()
{
- return 0;
+ jvmtiEnv *env = _Jv_GetJDWP_JVMTIEnv ();
+ jmethodID method = reinterpret_cast<jmethodID> (_methodId);
+ jint flags;
+ env->GetMethodModifiers (method, &flags);
+ return flags;
}
gnu::classpath::jdwp::util::LineTable *