473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

using JVMTI to get a collection with all instances of a class?

Hi,

basically, I'm trying to find a way to fetch all instances of a certain
class in Java, i.e. something like an allInstances() operator on
java.lang.Class, but obviously that doesn't exist.
I stumbled upon JVMTI, which seems to be able to access instances of a class
on the heap, using this function:
IterateOverInstancesOfClass(jvmtiEnv* env,
jclass klass,
jvmtiHeapObjectFilter object_filter,
jvmtiHeapObjectCallback heap_object_callback,
void* user_data)

Now a few things are unclear:
- is it possible to actually "call" this function from within a java
program? Because it seems jvmti is typically used in programs which run
outside the VM and just "monitor" it, so actually the java program is
unaware.
So maybe the only thing possible is generate an event and make sure the
monitor reacts?
- Supposing the function can be invoked somehow, will it be able to return a
value, and more specifically a collection of these instances? Or will it
only be able to collect information of these instances?
- Is there a better way to accomplish what I want?

Thanks,

Hans
Sep 19 '05 #1
1 5927
Hi Hans,

JVM TI can be called from JNI code. So simply create a native method
which calls the JVM TI function.

Since the heap walking functions operate on tags not objects, if you
want the return objects you will need to tag the objects with the
callbacks (they could all get the same tag). Then retrieve the
objects with GetObjectsWithTags.

As to if this is the best approach, that depends on what you are
trying to do. What are you trying to do?
Sent via Archivaty.com
Nov 3 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marc L'Ecuyer | last post by:
Hi, I have a collection class derived from CollectionBase. This collection can add items of my class MyItem. In my class MyItem, I have a Selected property. When this property is set to true, I...
4
by: m. pollack. | last post by:
Hi all, Is there any information to be had about the "Object Collection Editor" that appears when you click on a collection property in the PropertyGrid control? I have a class that maintains a...
1
by: Jellybean | last post by:
Hello, I believe it is possible to bind controls on forms to object instances, rather than to datasets. I need to be able to do this from Datagrid controls, and text box controls. Regards,...
12
by: Sunny | last post by:
Hi All, I have a serious issue regarding classes scope and visibility. In my application, i have a class name "TextFile", and also a few other classes like "TotalWords", "TotalLines" and etc..,...
3
by: User N | last post by:
Perhaps this is a stupid question, but here goes anyway. Given an instance of an arbitrary class, is it possible to change its base class at runtime? Here's my problem... I need to extend...
4
by: Rob Meade | last post by:
Hi all, I've been writing some .net classes at work now for a while and was feeling confident in my approach - until I attended a MS ASP.Net course! :o) Before the course, if I was going to...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
6
by: MooseMiester | last post by:
This little program just doesn't do what I think it should and I cannot understand what the problem is. I'm running Python 2.4 on Windoze XP. It contains an album class, an album collection...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.