This page assumes you are already familiar with the following concepts:

There are a few simple rules to follow when writing JNI code that handles Cocoa objects:

Always use JNF_COCOA_ENTER()/JNF_COCOA_EXIT()

As a rule, Java objects should own native objects in jlongs

Native objects held by Java objects must have a "hard" CF-retain count of 1 before being passed up to Java

Don't manage JNI global refs yourself

Don't put ObjC objects into C-structs