* src/native/jni.cpp: [OPENJDK] Implemented jni_GetDirectBufferCapacity.
[cacao.git] / tests / gc / NativeWeakRef.java
1 public class NativeWeakRef {
2         public native static void setWeakReference(Object o);
3         public native static Object getWeakReference();
4         public native static void delWeakReference();
5
6         public static void main(String args[]) {
7                 Object o;
8                 System.loadLibrary("native");
9
10                 /* create the object we want to deal with */
11                 o = new String("I am not important, you can forget me!");
12
13                 /* pass the object to the native world */
14                 setWeakReference(o);
15
16                 /* is the object still there? */
17                 o = getWeakReference();
18                 System.out.println(o);
19
20                 /* now forget about it and see if it gets collected */
21                 o = null;
22                 System.gc();
23
24                 /* is the object still there? */
25                 o = getWeakReference();
26                 System.out.println(o);
27
28                 /* delete the reference inside the native world */
29                 delWeakReference();
30         }
31 }