MCPcopy Index your code
hub / github.com/cretz/stackparam / populate_stack_params

Function populate_stack_params

src/native.rs:276–297  ·  view source on GitHub ↗
(jni_env: *mut JNIEnv, this: jobject, thread: jthread)

Source from the content-addressed store, hash-verified

274}
275
276unsafe fn populate_stack_params(jni_env: *mut JNIEnv, this: jobject, thread: jthread) -> Result<(), String> {
277 // Grab the depth we want
278 let mut depth = get_stack_trace_depth(jni_env, this)?;
279 if depth == 0 {
280 debug!("Unable to get stack trace depth, using {}", DEFAULT_MAX_STACK_DEPTH);
281 depth = DEFAULT_MAX_STACK_DEPTH;
282 }
283
284 // Load the stack params, skipping the first 2 by default which we know are not the caller
285 let mut params = get_params(jni_env, thread, depth + 10, 2)?;
286 // Only take the last so many to match the existing frame
287 if (depth as usize) < params.len() {
288 let to_remove_from_head = params.len() - (depth as usize);
289 params.drain(0..to_remove_from_head);
290 }
291
292 // Convert to object array
293 let params_arr = params_to_object_array(jni_env, params)?;
294 // Store in local field...
295 (**jni_env).SetObjectField.unwrap()(jni_env, this, get_stack_params_field(jni_env)?, params_arr);
296 return util::result_or_jni_ex((), jni_env);
297}
298
299unsafe fn get_throwable_class(jni_env: *mut JNIEnv) -> Result<jclass, String> {
300 let class_name_str = CString::new("java/lang/Throwable").unwrap();

Calls 6

get_stack_trace_depthFunction · 0.85
get_paramsFunction · 0.85
params_to_object_arrayFunction · 0.85
get_stack_params_fieldFunction · 0.85
result_or_jni_exFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected