I figured I'd do a feasibility study on whether JDI could be used to implement ObjectSpace (Ruby's feature for walking all objects on the heap of a given class). And it turns out it's possible, albeit extremely slow:
http://gist.github.com/259878 The basic logic here works this way: 1. attach a debugger to the current process 2. register a method entry request with the debugger for a prepared "hook class" 3. iterate over all object references as those method entry events fire, replacing references on the stack It's a hack, no doubt about it, but it's a cute hack. I'm essentially co-opting JDI to implement a runtime feature (live heap-walking) that normally would require JVMTI or equivalent native code. Comments, questions, hate mail welcome. - Charlie -- You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en.
