The low-level APIΒΆ
This API wraps the Java Native Interface (JNI) at the lowest level. It provides primitives for creating an environment and making calls on it.
Java array objects are handled as numpy arrays.
Each thread has its own environment. When you start a thread, you must attach to the VM to get that thread’s environment and access Java from that thread. You must detach from the VM before the thread exits.
In order to get the environment:
- Examples::
>>> env = get_env() >>> s = env.new_string(u"Hello, world.") >>> c = env.get_object_class(s) >>> method_id = env.get_method_id(c, "length", "()I") >>> method_id <Java method with sig=()I at 0xa0a4fd0> >>> result = env.call_method(s, method_id) >>> result 13