* Merged with default branch at rev 16f3633aaa5a.
[cacao.git] / tests / gc / NativeGlobalRef.java
1 public class NativeGlobalRef {
2         public native static void setReference(Object o);
3         public native static Object getReference();
4
5         public static void main(String args[]) {
6                 Object o;
7                 System.loadLibrary("native");
8
9                 /* create the object we want to deal with */
10                 o = new String("I am an important object, don't forget me!");
11                 //String s = "";
12                 //for (int i=0; i<100; i++)
13                 //      s = s + "I am an important object, don't forget me!";
14                 //o = s;
15                 //s = null;
16
17                 /* pass the object to the native world */
18                 setReference(o);
19
20                 /* now forget about it and see if it gets collected */
21                 o = null;
22                 System.gc();
23
24                 /* fill up the heap */
25                 //for (long i=0; i<100000000l; i++)
26                 //      o = new String("I am simply an heap filler!");
27
28                 /* is the object still there? */
29                 o = getReference();
30                 System.out.println(o);
31         }
32 }