If a JNI function returns a weak reference created with NewWeakGlobalRef, you'll get a class cast exception like this:
java.lang.ClassCastException: gnu.gcj.runtime.JNIWeakRef cannot be cast to org.gnu.glib.GObject at _Jv_CheckCast (/usr/lib/libgcj.so.6.0.0) -- Summary: JNI functions cannot return a weak reference Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: laurent at bearteam dot org CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org GCC build triplet: i486-pc-linux-gnu GCC host triplet: i486-pc-linux-gnu GCC target triplet: i486-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18278