* [RFA] Finding interpreter methods
@ 2006-01-20 17:19 Keith Seitz
2006-01-22 18:23 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2006-01-20 17:19 UTC (permalink / raw)
To: java-patches
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
Hi,
This might better be termed an RFC, but...
When the debugger gives us a method id, we need to find the
_Jv_InterpMethod for this method (which comes to us as a
java.lang.reflect.Method).
I didn't find any existing function which did this, so I wrote one,
which I am submitting here for approval.
Keith
ChangeLog
2006-01-18 Keith Seitz <keiths@redhat.com>
* java/lang/Class.h (_Jv_FindInterpreterMethod): Add new
declaration.
* java/lang/natClass.cc (_Jv_FindInterpreterMethod): New function.
[-- Attachment #2: find-interpmethod.patch --]
[-- Type: text/x-patch, Size: 2656 bytes --]
Index: java/lang/Class.h
===================================================================
--- java/lang/Class.h (revision 109992)
+++ java/lang/Class.h (working copy)
@@ -81,6 +81,12 @@
class _Jv_CompiledEngine;
class _Jv_InterpreterEngine;
+#ifdef INTERPRETER
+class _Jv_ClassReader;
+class _Jv_InterpClass;
+class _Jv_InterpMethod;
+#endif
+
struct _Jv_Constants
{
jint size;
@@ -217,6 +223,11 @@
jint JvNumMethods (jclass);
jmethodID JvGetFirstMethod (jclass);
+#ifdef INTERPRETER
+// Finds a desired interpreter method in the given class or NULL if not found
+_Jv_InterpMethod* _Jv_FindInterpreterMethod (jclass, jmethodID);
+#endif
+
// Friend classes and functions to implement the ClassLoader
class java::lang::ClassLoader;
class java::lang::VMClassLoader;
@@ -256,10 +267,6 @@
#ifdef INTERPRETER
void _Jv_InitField (jobject, jclass, int);
-
-class _Jv_ClassReader;
-class _Jv_InterpClass;
-class _Jv_InterpMethod;
#endif
class _Jv_StackTrace;
@@ -442,6 +449,10 @@
friend jmethodID (::_Jv_FromReflectedConstructor) (java::lang::reflect::Constructor *);
friend jint (::JvNumMethods) (jclass);
friend jmethodID (::JvGetFirstMethod) (jclass);
+#ifdef INTERPRETER
+ friend _Jv_InterpMethod* (::_Jv_FindInterpreterMethod) (jclass klass,
+ jmethodID desired_method);
+#endif
// Friends classes and functions to implement the ClassLoader
friend class java::lang::ClassLoader;
Index: java/lang/natClass.cc
===================================================================
--- java/lang/natClass.cc (revision 109992)
+++ java/lang/natClass.cc (working copy)
@@ -1,6 +1,6 @@
// natClass.cc - Implementation of java.lang.Class native methods.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation
This file is part of libgcj.
@@ -1220,3 +1220,29 @@
return false;
}
+
+#ifdef INTERPRETER
+_Jv_InterpMethod*
+_Jv_FindInterpreterMethod (jclass klass, jmethodID desired_method)
+{
+ using namespace java::lang::reflect;
+
+ _Jv_InterpClass* iclass
+ = reinterpret_cast<_Jv_InterpClass*> (klass->aux_info);
+ _Jv_MethodBase** imethods = _Jv_GetFirstMethod (iclass);
+
+ for (int i = 0; i < JvNumMethods (klass); ++i)
+ {
+ _Jv_MethodBase* imeth = imethods[i];
+ _Jv_ushort accflags = klass->methods[i].accflags;
+ if ((accflags & (Modifier::NATIVE | Modifier::ABSTRACT)) == 0)
+ {
+ _Jv_InterpMethod* im = reinterpret_cast<_Jv_InterpMethod*> (imeth);
+ if (im->get_method () == desired_method)
+ return im;
+ }
+ }
+
+ return NULL;
+}
+#endif
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Finding interpreter methods
2006-01-20 17:19 [RFA] Finding interpreter methods Keith Seitz
@ 2006-01-22 18:23 ` Tom Tromey
2006-01-23 18:45 ` Keith Seitz
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2006-01-22 18:23 UTC (permalink / raw)
To: Keith Seitz; +Cc: java-patches
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> I didn't find any existing function which did this, so I wrote one,
Keith> which I am submitting here for approval.
I'm surprised there isn't something like this already, but there you
have it. Looks good to me, thanks.
I see we're using the INTERPRETER define in Class.h. This is actually
wrong, since this define isn't JV_ namespaced and since it doesn't
make it into gcj/libgcj-config.h. This isn't your problem though, and
your patch doesn't make it any worse.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Finding interpreter methods
2006-01-22 18:23 ` Tom Tromey
@ 2006-01-23 18:45 ` Keith Seitz
0 siblings, 0 replies; 3+ messages in thread
From: Keith Seitz @ 2006-01-23 18:45 UTC (permalink / raw)
To: java-patches
Tom Tromey wrote:
>>>>>>"Keith" == Keith Seitz <keiths@redhat.com> writes:
>
>
> Keith> I didn't find any existing function which did this, so I wrote one,
> Keith> which I am submitting here for approval.
>
> I'm surprised there isn't something like this already, but there you
> have it. Looks good to me, thanks.
Done.
Thanks,
Keith
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-23 18:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-20 17:19 [RFA] Finding interpreter methods Keith Seitz
2006-01-22 18:23 ` Tom Tromey
2006-01-23 18:45 ` Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).