MCPcopy Create free account
hub / github.com/astonbitecode/j4rs / try_from

Method try_from

rust/src/api/mod.rs:226–441  ·  view source on GitHub ↗
(jni_environment: *mut JNIEnv)

Source from the content-addressed store, hash-verified

224 }
225
226 pub unsafe fn try_from(jni_environment: *mut JNIEnv) -> errors::Result<Jvm> {
227 if cache::get_thread_local_env_opt().is_none() {
228 // Create and set the environment in Thread Local
229 let _ = cache::get_jni_get_method_id().or_else(|| {
230 cache::set_jni_get_method_id(Some((**jni_environment).v1_6.GetMethodID))
231 });
232 let _ = cache::get_jni_get_static_method_id().or_else(|| {
233 cache::set_jni_get_static_method_id(Some(
234 (**jni_environment).v1_6.GetStaticMethodID,
235 ))
236 });
237 let _ = cache::get_jni_new_object()
238 .or_else(|| cache::set_jni_new_object(Some((**jni_environment).v1_6.NewObject)));
239 let _ = cache::get_jni_new_string_utf().or_else(|| {
240 cache::set_jni_new_string_utf(Some((**jni_environment).v1_6.NewStringUTF))
241 });
242 let _ = cache::get_jni_get_string_utf_chars().or_else(|| {
243 cache::set_jni_get_string_utf_chars(Some(
244 (**jni_environment).v1_6.GetStringUTFChars,
245 ))
246 });
247 let _ = cache::get_jni_release_string_utf_chars().or_else(|| {
248 cache::set_jni_release_string_utf_chars(Some(
249 (**jni_environment).v1_6.ReleaseStringUTFChars,
250 ))
251 });
252 let _ = cache::get_jni_call_object_method().or_else(|| {
253 cache::set_jni_call_object_method(Some((**jni_environment).v1_6.CallObjectMethod))
254 });
255 let _ = cache::get_jni_call_boolean_method().or_else(|| {
256 cache::set_jni_call_boolean_method(Some((**jni_environment).v1_6.CallBooleanMethod))
257 });
258 let _ = cache::get_jni_call_byte_method().or_else(|| {
259 cache::set_jni_call_byte_method(Some((**jni_environment).v1_6.CallByteMethod))
260 });
261 let _ = cache::get_jni_call_short_method().or_else(|| {
262 cache::set_jni_call_short_method(Some((**jni_environment).v1_6.CallShortMethod))
263 });
264 let _ = cache::get_jni_call_char_method().or_else(|| {
265 cache::set_jni_call_char_method(Some((**jni_environment).v1_6.CallCharMethod))
266 });
267 let _ = cache::get_jni_call_int_method().or_else(|| {
268 cache::set_jni_call_int_method(Some((**jni_environment).v1_6.CallIntMethod))
269 });
270 let _ = cache::get_jni_call_long_method().or_else(|| {
271 cache::set_jni_call_long_method(Some((**jni_environment).v1_6.CallLongMethod))
272 });
273 let _ = cache::get_jni_call_float_method().or_else(|| {
274 cache::set_jni_call_float_method(Some((**jni_environment).v1_6.CallFloatMethod))
275 });
276 let _ = cache::get_jni_call_double_method().or_else(|| {
277 cache::set_jni_call_double_method(Some((**jni_environment).v1_6.CallDoubleMethod))
278 });
279 let _ = cache::get_jni_call_void_method().or_else(|| {
280 cache::set_jni_call_void_method(Some((**jni_environment).v1_6.CallVoidMethod))
281 });
282 let _ = cache::get_jni_call_static_object_method().or_else(|| {
283 cache::set_jni_call_static_object_method(Some(

Callers

nothing calls this directly

Calls 15

get_thread_local_env_optFunction · 0.85
get_jni_get_method_idFunction · 0.85
set_jni_get_method_idFunction · 0.85
get_jni_new_objectFunction · 0.85
set_jni_new_objectFunction · 0.85
get_jni_new_string_utfFunction · 0.85
set_jni_new_string_utfFunction · 0.85

Tested by

no test coverage detected