If this is what you're trying to do, it isn't going to work. There is no
reference count. JNI performs special reference management when moving
between Java-land and native-land, but if it has any reference count at
all, it would only be for JNI references to Java objects.
If you want to know more how Java reclaims objects without reference
counts, I suggest reading up on how garbage collection works. If you
want to perform some special action when an object is collected, look
into creating a finalizer or a java.lang.ref.<xxx>Reference.
Eric wrote:[color=blue]
> Exemple:
> char[] a = new char[] {'a','b','c','d','e','f'};
> char[] b = a;
> MyClass.getReferenceCount( a ); // Suppose to be 2
> char[] c = a;
> MyClass.getReferenceCount( a ); // Suppose to be 3
> ...
>
>
> I thinked it was by using the JNI_N_REFS_IN_USE(frame) in jni.c ?
>
> In fact it's the same logic as GC do, even if it check only if a class
> is finalyzable ... but take a look in jni.c.
>
>
> jobject jni_mkRefLocal(ExecEnv *ee, JHandle *jobj){
> return (jobject) jni_addRef(ee->current_frame, jobj);
> }
>
> static JHandle **jni_addRef(JavaFrame *frame, JHandle *handle){
> ...
> }
>
>
>
> Thanks for your help.
>
>
>
>
dyksjare@hotmail.com (Jared Dykstra) wrote in message news:<ba84b53e.0401061221.10bc1aae@posting.google. com>...
>[color=green]
>>eric_beaumier@hotmail.com (Eric) wrote in message news:<6619720f.0401050455.6a4dfcfd@posting.google. com>...
>>[color=darkred]
>>>Hi,
>>>
>>>After reading the JNI specs, it looks like no JNI call is available to
>>>retrieve the reference count for a specific Java Object (LocalRef or
>>>GlobalRef).
>>>
>>>I would like to able to retrieve the "reference count", is it
>>>possible? Without using JVMPI or JVMDI ...
>>>
>>>Thanks[/color]
>>
>>
>>I'm not sure exactly what you are trying to do, but using JNI should
>>not be something you do if it can be avoided. Can the functionality
>>you are looking for be acheived through the java.lang.ref package? It
>>provides limited interaction with the GC.
>>
>>
http://java.sun.com/j2se/1.4.2/docs/...e-summary.html
>>
>>---
>>Jared Dykstra
>>
http://bork.org/~jared[/color][/color]