public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC/JVMTI] GetMethodDeclaringClass
@ 2006-10-17 18:09 Keith Seitz
  2006-10-17 18:14 ` Andrew Haley
  2006-10-17 18:23 ` Per Bothner
  0 siblings, 2 replies; 13+ messages in thread
From: Keith Seitz @ 2006-10-17 18:09 UTC (permalink / raw)
  To: Java Patch List

Hi,

Okay, well, I hate to be indecisive, but I've spent a lot of time being 
really wishy-washy on this, so I'm leaving it up to the collective 
wisdom of the maintainers and other developers. :-)

JVMTI has a function called GetMethodDeclaringClass which is a real 
pain. Unlike JDWP and JNI, JVMTI does *not* pass class IDs and method 
IDs together. JVMTI simply passes around the jmethodID. As a result, we 
have the evil known as GetMethodDeclaringClass, which is going to be 
required for JDWP (and probably any other real-world JVMTI agent).

So somehow we must maintain a mapping of jmethodIDs to their 
corresponding classes. I've played around with this quite a bit 
recently, and I've come to two solutions for this problem, both with 
pros and cons. [I have hacked both these solutions together; rough 
patches on request.]

It is up to you, gentle reader, to pick one of these solutions or offer 
another up for review. [I should mention a small aside: both JDWP and 
JVMTI also have a function to get all the classes in the VM for which 
this could also be used.]

1) the simple method
ClassLoaders already contain a list of all the classes they've loaded. 
So by adding some code to java.lang.ClassLoader, we can keep track of 
all the ClassLoaders in the system. We can then do several things to 
search through those loaded classes: loop through the classes (dog 
slow), sort the loaded classes and then search (I'm guessing not 
feasible for a large number of classes), etc.

2) maintain yet another list of loaded classes
Yes, I hate to say it, but this is on the table. If it isn't bad enough 
that java.lang.ClassLoader and the stacktracing code maintain lists of 
loaded classes, I'm proposing adding one more, which builds on the 
stacktracing code's _Jv_{Pop,Push}Class. I've implemented this with a 
TreeSet and a custom Comparator. [It maintains a list of classes, not 
jmethodIDs!]

3) ???

Any comments or other ideas?

Keith

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-10-28  2:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-17 18:09 [RFC/JVMTI] GetMethodDeclaringClass Keith Seitz
2006-10-17 18:14 ` Andrew Haley
2006-10-17 19:05   ` Andrew Haley
2006-10-17 18:42     ` Keith Seitz
2006-10-17 18:53       ` Andrew Haley
2006-10-18 23:04         ` Keith Seitz
2006-10-19  8:22           ` Andrew Haley
2006-10-23 20:50             ` Keith Seitz
2006-10-24  6:36               ` Andrew Haley
2006-10-27  0:06                 ` Keith Seitz
2006-10-27 10:17                   ` Andrew Haley
2006-10-28  2:16                     ` Keith Seitz
2006-10-17 18:23 ` Per Bothner

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).