...
- If you need to pass a Java object through native (like to the main AppKit thread, or inside of an NSArray), use JNFJObjectWrapper or JNFJObjectWeakWrapper
- It handles all the details of managing a JNI global ref in a native ObjC object in both RR and GC modes
- If you have a JNIEnv when you are done with the JNFJObjectWrapper, pre-clear the reference
- It is more efficient than the wrapper's -dealloc, which may have to connect the current thread to the JVM (possibly a ObjC-GC collector thread), just for the purposes of deleting the ref.
Don't put ObjC objects into C-structs
- The ObjC garbage collector can't find objects that have been stuffed into C arrays and structs
- If you must use a struct to hold onto a ObjC object (like some pieces of the graphics code currently does), you need to pin the ObjC using CFRetain(), just like if you were going to push it up into the JVM heap.
- Be sure to CFRelease() any AppKit objects on the main AppKit thread, so their -dealloc methods will be called on the right thread!
Overview
Content Tools
ThemeBuilder