I am trying to figure out a way to find a class instance inside a working JVM. The JVM is embedded into another process and an object is created by this process. The same process executes my Java code. I do not have a direct access to the Java object reference in my Java code, but I know the class of that object. I want to find out if there are objects of this class already instantiated in JVM, and if they are, I want to find them (get say an Object array with references to all the instances of this class). This mechanism can be either a Java API or an JNI API.
I know it is possible since debuggers let me inspect all instances. I just cannot seem to find the way.
Thanks
Nikita
In case anybody is curious, It is possible and I am doing it now using JVMTI. Not straightforward, but very doable. You can look at my other post about jvmti and you will find the answer.
Perplexed by jvmti object allocation callback behavior
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With