#[cfg(target_os="android")] #[allow(non_snake_case)] pub mod android { extern crate jni; use super::*; use self::jni::JNIEnv; use self::jni::objects::{JClass, JString}; use self::jni::sys::{jstring}; #[no_mangle] pub unsafe extern fn Java_rs_cph_hellorust_FFI_func(env: JNIEnv, _: JClass, java_pattern: JString) -> jstring { let world = rust_func(env.get_string(java_pattern).expect("invalid pattern string").as_ptr()); // Retake pointer, to use it below and allow memory to be freed when it goes out of scope. let world_ptr = CString::from_raw(world); let output = env.new_string(world_ptr.to_str().unwrap()).expect("Couldn't create java string!"); output.into_inner() } }